open3 process leaks?
I found a comment that hints at a problem I think I'm seeing, in which a fork
ed child of IPC::Open3 is running the main program code instead of just exec
ing like I would expect.
Does anyone else have experience with "leaking" processes out of IPC::Op开发者_运维问答en3? I looked over the library source, and didn't see anything outrageously wrong.
This is with Perl 5.8.4 (yeah, I know... but it can't be updated) running on Solaris 10.
While this has since been fixed, the open3
from 5.8.4 could throw an exception from the child, meaning both the parent and the child could "return" from open3
.
While you could handle that, it's a bit complicated.* It would be easier to replace your IPC/Open3.pm
with the one from a newer Perl.
Better yet, if you don't need something as low-level as IPC::Open3, you could use a higher-level module such as IPC::Run3 (simpler) or IPC::Run (more powerful).
* — At a minimum,
my $parent_pid = $$;
my $pid = eval { open3(...) };
if (!$pid) {
if ($parent_pid == $$) {
# Exception in parent.
die($@);
} else {
# Exception in child (pre-exec).
print STDERR $@;
_exit(255);
}
}
精彩评论