#!/usr/bin/perl use POSIX ":sys_wait_h"; print "process id: $$\n"; my $pid = fork; my $FH; unless($pid){ setpgrp; exec('./script'); } print "Child process id is: $pid\n"; for (1..5) { kill -9, $pid if $_ == 4; # kill children in the 4th round system "ps Tf -o etime,pid,pgrp,stat,cmd"; sleep(3); waitpid(-1, WNOHANG); }