use POSIX qw(WNOHANG); our (%PID); sub reaper { while ((my $kid = waitpid(-1,WNOHANG)) > 0 ) { warn "Reaped child with PID $kid"; my $status = $? >> 8; $PID{$kid} = $status; } }