bayruds has asked for the wisdom of the Perl Monks concerning the following question:
How do I ensure that the parent quits if its child/grand children exit.$SIG{CHLD} =\&reaper; my ($pid, $child_pid); if ($pid = fork) { print "[In Parent] After Fork\n"; # $SIG{CHLD} =\&reaper; } else { die "Unable to Fork: $!\n" unless(defined $pid); if ($child_pid = fork) { print "[In Child-Parent]\n"; my $cmd = ` <COMMAND! GOES HERE>`; if ($? eq 0) { print "@err\n"; print "[In Child-parent] Exitting\n"; exit(1); } # $SIG{CHLD} =\&reaper_sub; } else { print "[In Child-Child]\n"; my $cmd2 = `<COMMAND2 GOES HERE>`; if ($? eq 0) { print "Error in [Child]: Exitting\n"; exit(1); } } #End of child-child print "[In Child] End of Child\n"; } #End of Child
update (broquaint): added formatting + <code> tags
|
|---|