... setpgrp(0,0); sub killgroup { # Make sure all child processes are killed too. my $sig = shift; local $SIG{$sig} = 'IGNORE'; # don't kill ourselves again $Interrupted = 1; kill($sig, -$$); }; local $SIG{INT} = \&killgroup; local $SIG{QUIT} = \&killgroup; local $SIG{ABRT} = \&killgroup; local $SIG{TERM} = \&killgroup; local *CATCHERR = IO::File->new_tmpfile; my $pid = open3(gensym, \*CATCHOUT, ">&CATCHERR", "$cmd $args"); ...