#!/usr/local/bin/perl # parent code use strict; use warnings; my $pid; $SIG{TERM} = \&catch_sig; if( $pid = fork ) { # parent while( 1 ) { print "parent: $$, ", getpgrp, "\n"; sleep 2; } } else { exec ('./child.pl') or die "couldn't exec child.pl: $!"; } sub catch_sig { kill -15, getpgrp; exit; } #!/usr/local/bin/perl #child code --- nothing special here use strict; use warnings; while( 1 ) { print "child: $$, ", getpgrp, "\n"; sleep( 3 ); }