diff options
author | Philip Boulain <philip.boulain@smoothwall.net> | 2012-09-03 15:16:26 +0100 |
---|---|---|
committer | Tony Cook <tony@develop-help.com> | 2013-07-29 16:24:40 +1000 |
commit | cccbbce940ea952c4c236049e98d21a011475cb1 (patch) | |
tree | 072f77b804ddc06655305a7014734e4c8cff54cf /ext/IPC-Open3/lib | |
parent | 748cc03cd5ccfe4fb015da434bcb7dfb6125253b (diff) | |
download | perl-cccbbce940ea952c4c236049e98d21a011475cb1.tar.gz |
Reap child in case where exception has been thrown
If open3 throws due to an issue such as an exec failure, the caller
cannot know the child PID to wait for. Therefore it is our
responsibility to reap it.
Also update POD, since on some platforms exec failures now ARE raised as
exceptions (since perlbug #72016).
Diffstat (limited to 'ext/IPC-Open3/lib')
-rw-r--r-- | ext/IPC-Open3/lib/IPC/Open3.pm | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/ext/IPC-Open3/lib/IPC/Open3.pm b/ext/IPC-Open3/lib/IPC/Open3.pm index 989c2f65a9..f50146f8fa 100644 --- a/ext/IPC-Open3/lib/IPC/Open3.pm +++ b/ext/IPC-Open3/lib/IPC/Open3.pm @@ -57,7 +57,8 @@ as file descriptors. open3() returns the process ID of the child process. It doesn't return on failure: it just raises an exception matching C</^open3:/>. However, C<exec> failures in the child (such as no such file or permission denied), -are just reported to CHLD_ERR, as it is not possible to trap them. +are just reported to CHLD_ERR under Windows and OS/2, as it is not possible +to trap them. If the child process dies for any reason, the next write to CHLD_IN is likely to generate a SIGPIPE in the parent, which is fatal by default. @@ -297,6 +298,7 @@ sub _open3 { if ($bytes_read) { (my $bang, $to_read) = unpack('II', $buf); read($stat_r, my $err = '', $to_read); + waitpid $kidpid, 0; # Reap child which should have exited if ($err) { utf8::decode $err if $] >= 5.008; } else { |