On 4/6/06, John W. Krahn <[EMAIL PROTECTED]> wrote:
snip
> No, the lexical $handler holds the anonymous subroutine.
snip

Ah, you are right, the code should be

{ #setup the auto-reaper for fork'ed children
    my $handler;
    $handler = sub {
        my $pid;
        while (($pid = waitpid(-1, &WNOHANG)) > 0) {
            # do something with $pid
        }
        $SIG{CHLD} = $handler; #reinstall the handler
    }
    $SIG{CHLD} = $handler;
}

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to