use POSIX ":sys_wait_h"; SIG{CHLD} = \&REAPER; sub REAPER { 1 while (waitpid(-1,&WNOHANG) != -1); $SIG{CHLD} = \&REAPER; }