Skip Menu |

This queue is for tickets about the IPC-Cmd CPAN distribution.

Report information
The Basics
Id: 91784
Status: open
Priority: 0/
Queue: IPC-Cmd

People
Owner: Nobody in particular
Requestors: GAAS [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.90
Fixed in: (no value)



Subject: run_forked("/usr/bin/echo test") captures no output
For our HP-UX builds we get test failures from test 5 in t/03_run-forked.t about 80% of the time.  This can be reproduced with this simple script:

  #!perl
  use strict;
  use IPC::Cmd qw(run_forked);
  my $cmd = shift || "/usr/bin/echo test";
  my $r = run_forked($cmd);
  #use Data::Dump; dd $r;
  print "not " unless $r->{stdout} =~ /test/;
  print "ok\n";

When it fails the script hangs for about 9 seconds before it exits.  The failure to capture output also happens for simple commands like "ls /", not for more complex ones like "ls -l /" or "echo test; echo".  I believe this to be timing related.  It might look like the process doesn't get a chance to set up capturing for commands that execute quickly.

 perl -V
Summary of my perl5 (revision 5 version 16 subversion 3) configuration:
 
  Platform:
    osname=hpux, osvers=11.00, archname=PA-RISC1.1-thread-multi
    uname='hp-ux bertha b.11.00 u 9000800 136901587 unlimited-user license '
    config_args='-ders -Dcc=cc -Dusethreads -Duseithreads -Uinstallusrbinperl -Ulocincpth= -Uloclibpth= -Dsh=/usr/bin/sh -Dd_attribut=undef -Dd_attribute_warn_unused_result=undef -Dd_u32align=define -Aprepend:libswanted=cl  -Dvendorprefix=/home/gecko/ap1604/vendor -Dvendorlib=/home/gecko/ap1604/vendor/lib -Dvendorarch=/home/gecko/ap1604/vendor/lib -Darchname=PA-RISC1.1 -Accflags=+DAportable +DS2.0 -Doptimize=-O -Accflags=+Z -Accflags=-DUSE_SITECUSTOMIZE -Duselargefiles -Accflags=-DPERL_RELOCATABLE_INCPUSH -Dprefix=/home/gecko/ap1604 -Dprivlib=/home/gecko/ap1604/lib -Darchlib=/home/gecko/ap1604/lib -Dsiteprefix=/home/gecko/ap1604/site -Dsitelib=/home/gecko/ap1604/site/lib -Dsitearch=/home/gecko/ap1604/site/lib -Dsed=/usr/bin/sed -Duseshrplib -Dcf_by=ActiveState -Dcf_email=support@ActiveState.com'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=define, usemultiplicity=define
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=undef, use64bitall=undef, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags =' -D_POSIX_C_SOURCE=199506L -D_REENTRANT -Ae -D_HPUX_SOURCE -Wl,+vnocompatwarnings +DAportable +DS2.0 +Z -DUSE_SITECUSTOMIZE -DPERL_RELOCATABLE_INCPUSH -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 ',
    optimize='-O',
    cppflags='-Aa -D__STDC_EXT__ -D_HPUX_SOURCE -D_POSIX_C_SOURCE=199506L -D_REENTRANT -D_HPUX_SOURCE -Wl,+vnocompatwarnings +DAportable +DS2.0 +Z -DUSE_SITECUSTOMIZE -DPERL_RELOCATABLE_INCPUSH'
    ccversion='B.11.X.35098-35101.GP', gccversion='', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=4321
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='/usr/bin/ld', ldflags =''
    libpth=/lib /usr/lib /usr/ccs/lib /usr/local/lib
    libs=-lcl -lnsl -lnm -lndbm -lmalloc -ldld -lm -lcrypt -lsec -lpthread -lc
    perllibs=-lcl -lnsl -lnm -lmalloc -ldld -lm -lcrypt -lsec -lpthread -lc
    libc=/lib/libc.sl, so=sl, useshrplib=true, libperl=libperl.sl
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_hpux.xs, dlext=sl, d_dlsymun=undef, ccdlflags='-Wl,-E -Wl,-B,deferred '
    cccdlflags='+Z', lddlflags='-b +vnocompatwarnings'
 
 
Characteristics of this binary (from libperl):
  Compile-time options: HAS_TIMES MULTIPLICITY PERLIO_LAYERS
                        PERL_DONT_CREATE_GVSV PERL_IMPLICIT_CONTEXT
                        PERL_MALLOC_WRAP PERL_PRESERVE_IVUV
                        PERL_RELOCATABLE_INCPUSH USE_ITHREADS USE_LARGE_FILES
                        USE_LOCALE USE_LOCALE_COLLATE USE_LOCALE_CTYPE
                        USE_LOCALE_NUMERIC USE_PERLIO USE_PERL_ATOF
                        USE_REENTRANT_API USE_SITECUSTOMIZE
  Built under hpux
  Compiled at Dec 30 2013 13:11:43

I found that the problem goes away with this patch, but I have no idea why this works:

--- lib/IPC/Cmd.pm.orig Wed Jan  1 14:16:48 2014
+++ lib/IPC/Cmd.pm      Wed Jan  1 14:18:30 2014
@@ -517,6 +517,7 @@
   $child_err->autoflush(1);
 
   my $pid = open3($child_in, $child_out, $child_err, $cmd);
+  Time::HiRes::usleep(1);
 
   # push my child's pid to our parent
   # so in case i am killed parent
 
From: ppisar [...] redhat.com
Dne St 01.led.2014 17:20:47, GAAS napsal(a): Show quoted text
> --- lib/IPC/Cmd.pm.orig Wed Jan 1 14:16:48 2014 +++ lib/IPC/Cmd.pm Wed > Jan 1 > 14:18:30 2014 @@ -517,6 +517,7 @@ $child_err->autoflush(1); my $pid = > open3($child_in, $child_out, $child_err, $cmd); + > Time::HiRes::usleep(1); # > push my child's pid to our parent # so in case i am killed parent
Fixing race conditions by inserting arbitrary sleeps is wrong. It does not fix the cause, it only masks it. Unreliably. While using sleep in tests is quite cheap hack, doing it in the library code burdens everybody by slowing their code.