my $pid =fork; $SIG{INT} = sub { # got ctrl-c, sending sigterm to child kill 15, $pid; exit; }; if ($pid) {#parent waitpid($pid,0); } elsif (defined $pid) { for (5 .. 10) { print "sleeping $_\n"; system("sleep $_"); } exit; } else { ... }