$SIG{CHLD}=\&reaper; ... sub reaper { 1 while waitpid -1,&POSIX::WNOHANG != -1; $SIG{CHLD}=\&reaper; } #### use Errno; ... $select=new IO::Select(); $select->add(...); ... while (1) { $!=undef; while (@ready=$select->can_read()) { handle($_) foreach @ready; } die if $select->count() == 0; #should always have at least one last unless $! == EINTR; #try again; interrupted by signal } die if $! == ECHILD;