$SIG{CHLD}=\&catchChildDeath; # Deal with the death of a child. A sad event to be sure. sub catchChildDeath{ printf "Death of child noted.\n"; $children--; $children = ( $children < 0 ? 0 : $children); unless ($spawnEnabled){ $spawnEnabled = ( $children < $min_child ? 1 : 0 ); } printf "There are %d children running\n",$children; } #### sub my_child_work{ my $x = shift; print "child x $x "; sleep 1; exit; }