On Tue, Aug 17, 2004 at 08:22:09PM -0400, Jim wrote: >> [problem killing grandchildren when perl script runs from shell >> script] > your right the code is standard, I usually don't run perl scripts from shell > scripts except for cron jobs. I will take a look at some of my similar > scripts and see if I can find any kind of clue. Good Luck
The following subroutine seems to fix the problem, although I consider it a hack and I'm concerned because I don't think 'ps' behaves the same, even on all linux systems: sub KillAll { my $pid = shift; local $SIG{HUP} = 'IGNORE'; if (open PS, "ps -o pid,ppid |") { foreach my $line (<PS>) { kill HUP => $1 if ($line =~ /^\s*(\d+)\s*(\d+)\s*$/ and ($1 eq $pid or $2 eq $pid)); } close PS; } else { kill HUP => -$$; } } You call KillAll with a process ID and it kills that process and all its children. Can anyone suggest a better way to do this? Or does this seem like a reasonable way to accomplish the goal? -- Adam Rosi-Kessel http://adam.rosi-kessel.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>