Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Ted Zlatanov
October 2, 2009, 2:55 pm
rate this thread
I ran into a program (call it XYZ) that ignores SIGPIPE and many other
signals, so doing:
open J, "$command|" or die "Could not open command [$command]: $!";
would hang my program forever (XYZ gets SIGPIPE but never exits, so my
program waits on the child PID forever). I solved it like this:
# XYZ ignores SIGPIPE so we can't just close the pipe handle
# we have to kill every XYZ started in a subshell by us... annoying huh?
my @shells = `pgrep -P $$`;
foreach my $shell (@shells)
print "Killing XYZs with parent $shell\n";
system(pkill => -9 => -f => -P => $shell => 'XYZ');
Just a kill was not enough, it had to be -9.
Proc::ProcessTable was not available at the time, though I may use it
I was wondering if my approach was flawed and I am missing something
obvious, or if there's a better way to achieve this.
- » FAQ 5.14 How can I translate tildes (~) in a filename?
- — Next thread in » PERL Discussions
- » sort function warning, variable will not stay shared
- — Previous thread in » PERL Discussions