in reply to SIGCHLD and return codes
On most Unix platforms, the `CHLD' (sometimes also known as `CLD') signal has special behavior with respect to a value of `'IGNORE''. Setting `$SIG{CHLD}' to `'IGNORE'' on such a platform has the effect of not creating zombie processes when the parent process fails to `wait()' on its child processes (i.e. child processes are automatically reaped). Calling `wait()' with `$SIG{CHLD}' set to `'IGNORE'' usually returns `-1' on such platforms.I would install a signal handler that calls wait to reap the child process and get its exit status, as in this excerpt, adapted from perlipc:
sub REAPER { $waitedpid = wait; # now status is in $? print "reaped pid $waitedpid, exited with status ", $? >> 8, "\n"; # loathe sysV: it makes us not only reinstate # the handler, but place it after the wait $SIG{CHLD} = \&REAPER; } $SIG{CHLD} = \&REAPER;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: (sacked) Re: SIGCHLD and return codes
by shrubbery (Acolyte) on Nov 17, 2001 at 00:30 UTC | |
by sacked (Hermit) on Nov 17, 2001 at 00:50 UTC |