sub REAPER { while ((my $pid = waitpid(-1, &WNOHANG)) > 0) { if (WIFEXITED($?)) { } elsif (WIFSIGNALED($?)) { print "$?\n", $? >> 8, "\n", $? & 127, "\n"; print( "child exited with signal: ", WTERMSIG($?), "\n"); } elsif (WIFSTOPPED($?)) { print "child stopped????\n"; next; } else { print "hmmm\n"; } delete $children{$pid}; $children--; print "$children children running\n"; } $SIG{CHLD} = \&REAPER; #probably not needed, but paranoia }