use POSIX ":sys_wait_h"; sub reaper { do { $kid = waitpid(-1, WNOHANG); } while $kid > 0; } $SIG{CHLD} = \&reaper;