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;