In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/a0ed8b7b5f7f6d6f98f7eab4d4b280d5922b2df2?hp=83f8bb564961ee8fba35156e720bef403d8fa9a7>

- Log -----------------------------------------------------------------
commit a0ed8b7b5f7f6d6f98f7eab4d4b280d5922b2df2
Author: Father Chrysostomos <[email protected]>
Date:   Sun Sep 26 06:40:52 2010 -0700

    tests for [perl #76474]

M       MANIFEST
A       ext/IPC-Open3/t/fd.t

commit fb9b5b31d8a62644191f4e414a66124e86f30797
Author: Vernon Lyon <[email protected]>
Date:   Sun Sep 26 06:34:58 2010 -0700

    [perl #76474]: IPC::Open3 doesn't handle file descriptors correctly
    
    In the POD docs it says:
    "The filehandles may also be integers, in which case they are under-
    stood as file descriptors."
    
    However IPC::Open3 doesn't handle the file descriptors correctly.
    As an example, if we try to dup STDIN in a child process by using it's
    file descriptor, we get:
    
    > perl -MIPC::Open3 -wle 'open3("<&1", my $out, undef, $^X)'
    close() on unopened filehandle 1 at /usr/share/perl/5.10/IPC/Open3.pm line 
70.
    open3: close(1) failed: Bad file descriptor at -e line 1
    
    This is because in IPC::Open3 the subroutines xpipe*, xclose* and
    xopen don't cater for descriptors being passed in instead of
    filehandles.

M       ext/IPC-Open3/lib/IPC/Open3.pm
-----------------------------------------------------------------------

Summary of changes:
 MANIFEST                       |    1 +
 ext/IPC-Open3/lib/IPC/Open3.pm |    2 +-
 ext/IPC-Open3/t/fd.t           |   15 +++++++++++++++
 3 files changed, 17 insertions(+), 1 deletions(-)
 create mode 100644 ext/IPC-Open3/t/fd.t

diff --git a/MANIFEST b/MANIFEST
index a9cff35..65ceec5 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -3178,6 +3178,7 @@ ext/I18N-Langinfo/t/Langinfo.t    See whether 
I18N::Langinfo works
 ext/IPC-Open2/lib/IPC/Open2.pm Open a two-ended pipe
 ext/IPC-Open2/t/IPC-Open2.t    See if IPC::Open2 works
 ext/IPC-Open3/lib/IPC/Open3.pm Open a three-ended pipe
+ext/IPC-Open3/t/fd.t           See if IPC::Open3 works w/ file descriptors
 ext/IPC-Open3/t/IPC-Open3.t    See if IPC::Open3 works
 ext/mro/Changes                        mro extension
 ext/mro/mro.pm                 mro extension
diff --git a/ext/IPC-Open3/lib/IPC/Open3.pm b/ext/IPC-Open3/lib/IPC/Open3.pm
index 50ae61e..879469e 100644
--- a/ext/IPC-Open3/lib/IPC/Open3.pm
+++ b/ext/IPC-Open3/lib/IPC/Open3.pm
@@ -181,7 +181,7 @@ sub xopen {
 }
 
 sub xclose {
-    close $_[0] or croak "$Me: close($_[0]) failed: $!";
+    $_[0] =~ /\A=?(\d+)\z/ ? eval { require POSIX; POSIX::close($1); } : close 
$_[0]
 }
 
 sub fh_is_fd {
diff --git a/ext/IPC-Open3/t/fd.t b/ext/IPC-Open3/t/fd.t
new file mode 100644
index 0000000..2a9aeff
--- /dev/null
+++ b/ext/IPC-Open3/t/fd.t
@@ -0,0 +1,15 @@
+#!./perl
+
+BEGIN { require "../../t/test.pl"; }
+use strict;
+use warnings;
+
+plan 1;
+
+# [perl #76474]
+ok !runperl(
+     switches => ['-MIPC::Open3', '-w'],
+     prog => 'open3(q _<&1_, my $out, undef, $ENV{PERLEXE})',
+     stderr => 1,
+   ),
+   "dup STDIN in a child process by using its file descriptor";

--
Perl5 Master Repository

Reply via email to