{ local $SIG{HUP} = 'IGNORE'; kill HUP => -$$; } #### #!/opt/perl/bin/perl use 5.012; use warnings; say "A start"; my $pid; unless ( $pid = fork ) { die "cannot fork: $!" unless defined $pid; system("./b.pl"); sleep 30; exit; } sleep 2; say "A sending kill HUP -$$"; { local $SIG{HUP} = 'IGNORE'; kill HUP => -$$; } say "A waiting for lost children"; while (1) { my $kid = waitpid -1, 0; $kid == -1 and last; say "A reaped child $kid"; } say "A end"; #### #!/opt/perl/bin/perl use 5.012; use warnings; say " B start"; my $pid; unless ($pid = fork) { die "cannot fork: $!" unless defined $pid; system("./c.pl"); sleep 30; exit; } say " B waiting on lost children"; while (1) { my $kid = waitpid -1, 0; $kid == -1 and last; say " B reaped child $kid"; } sleep 30; say " B end"; #### #!/opt/perl/bin/perl use 5.012; use warnings; say " C start"; sleep 30; say " C exit"; #### $ ./a.pl A start B start B waiting on lost children C start A sending kill HUP -20682 A waiting for lost children A reaped child 20683 A end