N
Nitzan Shaked
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{$child} = $?;
}
$SIG{CHLD} = \&REAPER; # still loathe sysV
}
$SIG{CHLD} = \&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?
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{$child} = $?;
}
$SIG{CHLD} = \&REAPER; # still loathe sysV
}
$SIG{CHLD} = \&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?