Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IPC::Open3::open3(..., '-') broken #11527

Closed
p5pRT opened this issue Jul 27, 2011 · 8 comments
Closed

IPC::Open3::open3(..., '-') broken #11527

p5pRT opened this issue Jul 27, 2011 · 8 comments

Comments

@p5pRT
Copy link

p5pRT commented Jul 27, 2011

Migrated from rt.perl.org#95748 (status was 'resolved')

Searchable as RT95748$

@p5pRT
Copy link
Author

p5pRT commented Jul 27, 2011

From @salva

Created by @salva

IPC​::Open3​::open3($in, $out, $err, '-') is broken in 5.14.1

Because the old "return 0" used to return to user code now is wrapped inside and eval block.

The following patch solves the problem​:

====================================================================

Inline Patch
--- Open3.pm~    2011-07-27 10:09:39.072915811 +0200
+++ Open3.pm    2011-07-27 12:30:08.066949005 +0200
@@ -284,12 +284,15 @@
         } else {
             xopen \*STDERR, ">&STDOUT" if fileno(STDERR) != fileno(STDOUT);
         }
-        return 0 if ($cmd[0] eq '-');
+        return 1 if ($cmd[0] eq '-');
         exec @cmd or do {
             local($")=(" ");
             croak "$Me: exec of @cmd failed";
         };
-        };
+        } and do {
+                close $stat_w;
+                return 0;
+            };
 
         my $bang = 0+$!;
         my $err = $@;
====================================================================
Perl Info

Flags:
    category=library
    severity=high
    module=IPC::Open3

Site configuration information for perl 5.14.1:

Configured by salva at Wed Jul 27 09:56:26 CEST 2011.

Summary of my perl5 (revision 5 version 14 subversion 1) configuration:
   
  Platform:
    osname=linux, osvers=3.0.0-5-generic, archname=x86_64-linux
    uname='linux leon 3.0.0-5-generic #6-ubuntu smp tue jul 12 05:21:50 utc 2011 x86_64 x86_64 x86_64 gnulinux '
    config_args=''
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=undef, usemultiplicity=undef
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=define, use64bitall=define, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O2',
    cppflags='-fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include'
    ccversion='', gccversion='4.6.1', gccosandvers=''
    intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -fstack-protector -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib /usr/lib/x86_64-linux-gnu /lib64 /usr/lib64
    libs=-lnsl -ldl -lm -lcrypt -lutil -lc
    perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
    libc=, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version='2.13'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
    cccdlflags='-fPIC', lddlflags='-shared -O2 -L/usr/local/lib -fstack-protector'

Locally applied patches:
    


@INC for perl 5.14.1:
    /usr/local/perl/5.14.1//lib/site_perl/5.14.1/x86_64-linux
    /usr/local/perl/5.14.1//lib/site_perl/5.14.1
    /usr/local/perl/5.14.1//lib/5.14.1/x86_64-linux
    /usr/local/perl/5.14.1//lib/5.14.1
    .


Environment for perl 5.14.1:
    HOME=/home/salva
    LANG=en_US.UTF-8
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
    PERL_BADLANG (unset)
    SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Jul 27, 2011

From @salva

patch attached, as the version I included inline seems mangled

@p5pRT
Copy link
Author

p5pRT commented Jul 27, 2011

From @salva

open3.patch
--- Open3.pm~	2011-07-27 10:09:39.072915811 +0200
+++ Open3.pm	2011-07-27 12:30:08.066949005 +0200
@@ -284,12 +284,15 @@
 		} else {
 		    xopen \*STDERR, ">&STDOUT" if fileno(STDERR) != fileno(STDOUT);
 		}
-		return 0 if ($cmd[0] eq '-');
+		return 1 if ($cmd[0] eq '-');
 		exec @cmd or do {
 		    local($")=(" ");
 		    croak "$Me: exec of @cmd failed";
 		};
-	    };
+	    } and do {
+                close $stat_w;
+                return 0;
+            };
 
 	    my $bang = 0+$!;
 	    my $err = $@;

@p5pRT
Copy link
Author

p5pRT commented Jul 27, 2011

From [Unknown Contact. See original ticket]

patch attached, as the version I included inline seems mangled

@p5pRT
Copy link
Author

p5pRT commented Jul 27, 2011

@salva - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Jul 27, 2011

From @cpansprout

On Wed Jul 27 03​:48​:31 2011, salva wrote​:

patch attached, as the version I included inline seems mangled

Thank you for the patch. I can confirm it works, and have applied it as
f8b0429.

Is there any chance you could write a test for that? (My last few
attempts at writing tests for IPC stuff ended in catastrophic failure.)

@p5pRT
Copy link
Author

p5pRT commented Jul 27, 2011

@cpansprout - Status changed from 'open' to 'resolved'

@p5pRT p5pRT closed this as completed Jul 27, 2011
@p5pRT
Copy link
Author

p5pRT commented Mar 6, 2012

From @zmanda-pusher1

On Wed Jul 27 09​:22​:21 2011, sprout wrote​:

On Wed Jul 27 03​:48​:31 2011, salva wrote​:

patch attached, as the version I included inline seems mangled

Thank you for the patch. I can confirm it works, and have applied it as
f8b0429.

Can you commit the patch to the maint-5.14 branch?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant