use POSIX qw(:syswait_h); while ((my $pid = waitpid(-1, WNOHANG)) != -1) { kill 9, $pid; }