perlipc doc / another race (?)

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

This is realted to the perlipc but not necessarily to perl itself so
much as to plain unix signals. Still, I hope you accomodate this.

Reading perlipc, the first part (re signals) there is this code example
towards the end of that part:

 use POSIX ":sys_wait_h";
    sub REAPER {
    my $child;
    # If a second child dies while in the signal handler caused by the
    # first death, we won't get another signal. So must loop here else
    # we will leave the unreaped child as a zombie. And the next time
    # two children die we get another zombie. And so on.
        while (($child = waitpid(-1,WNOHANG)) > 0) {
        $Kid_Status = $?;
    $SIG = \&REAPER;  # still loathe sysV
    $SIG = \&REAPER;
    # do something that forks...

==> It says that it loops in the handler to catch and other SIGCHLD's
that might happen during the execution of the handler, and for which
the handler will not be invoked again.

It seems to me like if a child terminates after the while's closing
brace (1 uSec after...) then the signal is lost! It (the child) will
not be reaped by the current handler, but will also not be signalled.

How am I suppose to reap such children, then?

Re: perlipc doc / another race (?)

Quoted text here. Click to load it

Repair the corrupted file:

   perl -p -i -e 'tr/\r//d' bad_file

    Tad McClellan                          SGML consulting                   Perl programming
    Fort Worth, Texas

Site Timeline