#set the sig handler for when a child dies $SIG{CHLD} = \&REAPER; #signal routine to wait for all children (prevents zombies) sub REAPER { #WNOHANG means to return immediately if no child has exited. while ((waitpid(-1, WNOHANG)) >0 ){} #reset the sig for the next child to die; $SIG{CHLD} = \&REAPER; }