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 child may return in the child process #7424

Closed
p5pRT opened this issue Jul 16, 2004 · 4 comments
Closed

IPC::Open3 child may return in the child process #7424

p5pRT opened this issue Jul 16, 2004 · 4 comments

Comments

@p5pRT
Copy link

p5pRT commented Jul 16, 2004

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

Searchable as RT30715$

@p5pRT
Copy link
Author

p5pRT commented Jul 16, 2004

From gus@debian.org

Created by gus@debian.org

IPC​::Open3​::open3() ends up running (simplified)​:

  $kidpid = fork;
  if ($kidpid == 0) { # Kid
  ...
  exec @​cmd
  or croak "$Me​: exec of @​cmd failed";
  }

It is unreasonable to expect that the croak() may cause the child
process to exit. Any time the exec fails inside an eval{}, the child
process will continue to be alive.

IMO open3 should just warn and POSIX​::_exit(1) on errors in the child.
(I can't even think of any case you would *want* to catch errors in
the child process itself)

Note that IPC​::Open2 calls the same function, so also suffers from
the same problem.

- Gus

Perl Info

Flags:
    category=library
    severity=low

Site configuration information for perl v5.8.3:

Configured by Debian Project at Sat Mar 27 17:07:14 EST 2004.

Summary of my perl5 (revision 5.0 version 8 subversion 3) configuration:
  Platform:
    osname=linux, osvers=2.4.25-ti1211, archname=i386-linux-thread-multi
    uname='linux kosh 2.4.25-ti1211 #1 thu feb 19 18:20:12 est 2004 i686 gnulinux '
    config_args='-Dusethreads -Duselargefiles -Dccflags=-DDEBIAN -Dcccdlflags=-fPIC -Darchname=i386-linux -Dprefix=/usr -Dprivlib=/usr/share/perl/5.8 -Darchlib=/usr/lib/perl/5.8 -Dvendorprefix=/usr -Dvendorlib=/usr/share/perl5 -Dvendorarch=/usr/lib/perl5 -Dsiteprefix=/usr/local -Dsitelib=/usr/local/share/perl/5.8.3 -Dsitearch=/usr/local/lib/perl/5.8.3 -Dman1dir=/usr/share/man/man1 -Dman3dir=/usr/share/man/man3 -Dsiteman1dir=/usr/local/man/man1 -Dsiteman3dir=/usr/local/man/man3 -Dman1ext=1 -Dman3ext=3perl -Dpager=/usr/bin/sensible-pager -Uafs -Ud_csh -Uusesfio -Uusenm -Duseshrplib -Dlibperl=libperl.so.5.8.3 -Dd_dosuid -des'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=define use5005threads=undef 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_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -DDEBIAN -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O3',
    cppflags='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -DDEBIAN -fno-strict-aliasing -I/usr/local/include'
    ccversion='', gccversion='3.3.3 (Debian 20040314)', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=4, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lgdbm -lgdbm_compat -ldb -ldl -lm -lpthread -lc -lcrypt
    perllibs=-ldl -lm -lpthread -lc -lcrypt
    libc=/lib/libc-2.3.2.so, so=so, useshrplib=true, libperl=libperl.so.5.8.3
    gnulibc_version='2.3.2'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
    cccdlflags='-fPIC', lddlflags='-shared -L/usr/local/lib'

Locally applied patches:
    


@INC for perl v5.8.3:
    /etc/perl
    /usr/local/lib/perl/5.8.3
    /usr/local/share/perl/5.8.3
    /usr/lib/perl5
    /usr/share/perl5
    /usr/lib/perl/5.8
    /usr/share/perl/5.8
    /usr/local/lib/site_perl
    /usr/local/lib/perl/5.8.0
    /usr/local/share/perl/5.8.0
    .


Environment for perl v5.8.3:
    HOME=/home/gus
    LANG=en_AU
    LANGUAGE=en_AU
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/home/gus/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games
    PERL_BADLANG (unset)
    SHELL=/bin/zsh

@p5pRT
Copy link
Author

p5pRT commented Mar 20, 2007

From guest@guest.guest.xxxxxxxx

Two comments​:

1. It's not just the exec call, there are a number of system calls that
can at least theoretically fail (all the calls to xfork, xopen, and
xclose, which croak if the functions they wrap report failure).

2. A normal exit causes DESTROY to be called on objects, which may or
may not be wanted. For example, if you create a File​::Temp object in
order to direct output to it by passing its descriptor to open3, and
the exec (or anything else) in the child fails, and the child exits,
then the temporary file is automatically unlinked. When the parent also
attempts to unlink it, a warning is emitted (with use warnings).

I think it can be okay to croak in the child, but there should be a
warning about evals in the documentation, $@​ should be set to something
that makes it easy to tell that you're in the child process after the
eval, and if there is no eval, the exit status should be set to
something that makes it easier to tell a pre-exec error from an exit
status coming from the exec​:ed program.

@p5pRT
Copy link
Author

p5pRT commented Mar 20, 2007

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented May 31, 2008

p5p@spam.wizbit.be - Status changed from 'open' to 'resolved'

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

No branches or pull requests

1 participant