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

A perl program can die() with exit status zero. #211

Closed
p5pRT opened this issue Jul 20, 1999 · 1 comment
Closed

A perl program can die() with exit status zero. #211

p5pRT opened this issue Jul 20, 1999 · 1 comment

Comments

@p5pRT
Copy link

p5pRT commented Jul 20, 1999

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

Searchable as RT1017$

@p5pRT
Copy link
Author

p5pRT commented Jul 20, 1999

From GilesA@ctxuk.citrix.com

I have found that under some circumstances, a Perl script can
exit by calling die(), and returns to the OS with an exit status
of zero. As the perlfunc manual page documents the considerable
lengths that die() goes to produce a meaningful non-zero exit
status, I am interpreting this behaviour as a bug.

Attached below is a short Perl program that demonstrates the
problem. If run without an argument it exits with status zero.
Supplying an argument causes it to close the pipe and it then
produces a non-zero status. I have found that if the parent
process does not read from the pipe, then the exit status
is non-zero in both cases.

Attached below that is output from two test runs with
Perl 5.005_03 and one from 5.004_04.

Thank you,

Giles


-------------------- Cut here​: pipe.pl
#! /usr/local/bin/perl -w
# Test behaviour of die()with open pipes.

use IO​::File;

my($foo, $pid, $irfh);

$irfh = new IO​::File;
$pid = open($irfh, '-|');
if (!$pid) {
  print "I am the child\n";
  exit 0;
}
$foo = <$irfh>;
if ($#ARGV >= 0) {
# print "Closing pipe\n";
  $irfh->close;
}
die("Suicide");


-------------------- Cut here​: perl 5.005_3/IRIX
Script started on Tue Jul 20 09​:16​:32 1999
$ perl -V
Summary of my perl5 (5.0 patchlevel 5 subversion 3) configuration​:
  Platform​:
  osname=irix, osvers=6.3, archname=IP32-irix
  uname='irix tesco 6.3 12161207 ip32 '
  hint=recommended, useposix=true, d_sigaction=define
  usethreads=undef useperlio=undef d_sfio=undef
  Compiler​:
  cc='cc -n32', optimize='-O3', gccversion=
  cppflags='-D_BSD_TYPES -D_BSD_TIME -OPT​:Olimit=0 -I/usr/local/include
-DLANGUAGE_C'
  ccflags ='-D_BSD_TYPES -D_BSD_TIME -woff 1009,1110,1184 -OPT​:Olimit=0
-I/usr/local/include -DLANGUAGE_C'
  stdchar='unsigned char', d_stdstdio=define, usevfork=false
  intsize=4, longsize=4, ptrsize=4, doublesize=8
  d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
  alignbytes=8, usemymalloc=y, prototype=define
  Linker and Libraries​:
  ld='cc -n32', ldflags =' -L/usr/local/lib32 -L/usr/local/lib'
  libpth=/usr/local/lib /usr/lib32 /lib32 /lib /usr/lib
  libs=-lm -lc
  libc=/usr/lib32/libc.so, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking​:
  dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
  cccdlflags=' ', lddlflags='-n32 -shared -L/usr/local/lib32
-L/usr/local/lib'

Characteristics of this binary (from libperl)​:
  Built under irix
  Compiled at Jul 20 1999 09​:07​:34
  @​INC​:
  /usr/local/lib/perl5/5.00503/IP32-irix
  /usr/local/lib/perl5/5.00503
  /usr/local/lib/perl5/site_perl/5.005/IP32-irix
  /usr/local/lib/perl5/site_perl/5.005
  .
$ perl pipe.pl
Suicide at pipe.pl line 19, <GEN0> chunk 1.
$ echo $?
0
$ perl pipe.pl anarg
Suicide at pipe.pl line 19.
$ echo $?
255
$

script done on Tue Jul 20 09​:17​:35 1999


-------------------- Cut here​: perl 5.004_4/Linux
$ (perl -V; perl pipe.pl; echo $?; perl pipe.pl anarg; echo $?)

Summary of my perl5 (5.0 patchlevel 4 subversion 4) configuration​:
  Platform​:
  osname=linux, osvers=2.0.34, archname=i386-linux
  uname='linux porky.redhat.com 2.0.34 #1 thu may 7 10​:17​:44 edt 1998 i686
unknown '
  hint=recommended, useposix=true, d_sigaction=define
  bincompat3=y useperlio=undef d_sfio=undef
  Compiler​:
  cc='cc', optimize='-O2', gccversion=2.7.2.3
  cppflags='-Dbool=char -DHAS_BOOL -I/usr/local/include'
  ccflags ='-Dbool=char -DHAS_BOOL -I/usr/local/include'
  stdchar='char', d_stdstdio=define, usevfork=false
  intsize=4, longsize=4, ptrsize=undef, doublesize=undef
  alignbytes=4, usemymalloc=n, prototype=define
  Linker and Libraries​:
  ld='cc', ldflags =' -L/usr/local/lib'
  libpth=/usr/local/lib /lib /usr/lib
  libs=-lnsl -lndbm -lgdbm -ldb -ldl -lm -lc -lposix -lcrypt
  libc=, so=so
  useshrplib=false, libperl=libperl.a
  Dynamic Linking​:
  dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
  cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'

Characteristics of this binary (from libperl)​:
  Locally applied patches​:
  MAINT_TRIAL_4 - 5.004_05 maintenance trial 4
  Built under linux
  Compiled at Sep 10 1998 02​:16​:22
  %ENV​:
  PERL5LIB="/home/alex/lib/site_perl/mirror"
  @​INC​:
  /home/alex/lib/site_perl/mirror
  /usr/lib/perl5/i386-linux/5.00404
  /usr/lib/perl5
  /usr/lib/perl5/site_perl/i386-linux
  /usr/lib/perl5/site_perl
  .
Suicide at pipe.pl line 18, <GEN0> chunk 1.
0
Suicide at pipe.pl line 18.
29


-------------------- Cut here​: perl 5.005_3/Linux
$ (perl -V; perl pipe.pl; echo $?; perl pipe.pl anarg; echo $?)

Summary of my perl5 (5.0 patchlevel 5 subversion 3) configuration​:
  Platform​:
  osname=linux, osvers=2.0.36, archname=i686-linux
  uname='linux rothko.anvil.co.uk 2.0.36 #1 tue oct 13 22​:17​:11 edt 1998
i686 unknown '
  hint=recommended, useposix=true, d_sigaction=define
  usethreads=undef useperlio=undef d_sfio=undef
  Compiler​:
  cc='cc', optimize='-O2', gccversion=2.7.2.3
  cppflags='-Dbool=char -DHAS_BOOL -I/usr/local/include'
  ccflags ='-Dbool=char -DHAS_BOOL -I/usr/local/include'
  stdchar='char', d_stdstdio=define, usevfork=false
  intsize=4, longsize=4, ptrsize=4, doublesize=8
  d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
  alignbytes=4, usemymalloc=n, prototype=define
  Linker and Libraries​:
  ld='cc', ldflags =' -L/usr/local/lib'
  libpth=/usr/local/lib /lib /usr/lib
  libs=-lnsl -lndbm -lgdbm -ldb -ldl -lm -lc -lposix -lcrypt
  libc=, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking​:
  dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
  cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'

Characteristics of this binary (from libperl)​:
  Built under linux
  Compiled at Jul 5 1999 12​:28​:00
  %ENV​:

PERL5LIB="./perlidl​:/home/alex/trees/ate/build/lib/site_perl​:/home/alex/tree
s/ate/build/lib/site_perl/perlidl"
  @​INC​:
  ./perlidl
  /home/alex/trees/ate/build/lib/site_perl
  /home/alex/trees/ate/build/lib/site_perl/perlidl
  /installed/perl5.005/lib/5.00503/i686-linux
  /installed/perl5.005/lib/5.00503
  /installed/perl5.005/lib/site_perl/5.005/i686-linux
  /installed/perl5.005/lib/site_perl/5.005
  .
Suicide at pipe.pl line 18, <GEN0> chunk 1.
0
Suicide at pipe.pl line 18.
29

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