$SIG{'CHLD'}=sub { my $pid=wait(); if ($pid == -1 ) { print "SIGCHLD handler called without dead child.\n"; return; } print "Child $pid exited with $?\n"; }