FAQ
This is a bug report for perl from shy@cig.mot.com,
generated with the help of perlbug 1.26 running under perl 5.00502.

system() corrupts exit status after exit()

system() corrupts the exit status of a script if the system calls takes place
after the script calls exit().

The following scripts demonstrate the problem when called with any argument.

'ptest2 1' invokes system() in an END block after the script calls exit(1).

'ptest 1' invokes system() in an object destructor after the script calls
exit(1).

In both cases, each script's final exit status is 0. I think this behavior
qualifies as a perl bug since the final exit statuses are 0 when the system()
calls aren't made. Try 'ptest2' and 'ptest'.

I see this problem with perl, version 5.005_02 built for sun4-solaris or
sun4-sunos.

######### ptest2 BEGIN

#!/opt/local/bin/perl5 -w

main();

sub main {
exit 1;
}

END {
if(@ARGV) { system("false") };
print "end block done\n";
}

######### ptest2 END

######### ptest BEGIN

#!/opt/local/bin/perl5 -w

package A;

sub new {
my($c) = @_;
return bless {}, $c;
}


DESTROY {
my($r) = @_;
if(%$r) { system("false") };
print "destroyed $r\n";
}


package main;

main();

sub main {
my($r) = A->new();
if(@ARGV) { $r->{@ARGV}++ }
exit 1;
}

####### ptest END

---
Site configuration information for perl 5.00502:

Configured by youngdj at Thu Dec 17 06:12:23 CST 1998.

Summary of my perl5 (5.0 patchlevel 5 subversion 2) configuration:
Platform:
osname=solaris, osvers=2.6, archname=sun4-solaris
uname='sunos dev0 5.6 generic_105181-11 sun4u sparc sunw,ultra-2 '
hint=recommended, useposix=true, d_sigaction=define
usethreads=undef useperlio=undef d_sfio=undef
Compiler:
cc='gcc', optimize='-O', gccversion=2.8.1
cppflags=''
ccflags =''
stdchar='unsigned char', d_stdstdio=define, usevfork=true
intsize=4, longsize=4, ptrsize=4, doublesize=8
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
alignbytes=8, usemymalloc=n, prototype=define
Linker and Libraries:
ld='gcc', ldflags =' -L/opt/gnu/lib'
libpth=/opt/gnu/lib /usr/lib /usr/ccs/lib
libs=-lsocket -lnsl -ldl -lm -lc -lcrypt
libc=/lib/libc.so, so=so, useshrplib=false, libperl=libperl.a
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
cccdlflags='-fPIC', lddlflags='-G -L/opt/gnu/lib'

Locally applied patches:


---
@INC for perl 5.00502:
/opt/gnu/lib/perl5/5.00502/sun4-solaris
/opt/gnu/lib/perl5/5.00502
/opt/gnu/lib/perl5/site_perl/5.005/sun4-solaris
/opt/gnu/lib/perl5/site_perl/5.005
.

---
Environment for perl 5.00502:
HOME=/home/shy
LANG=C
LC_ALL=
LC_COLLATE=
LC_CTYPE=
LC_MESSAGES=
LC_MONETARY=
LC_NUMERIC=
LC_TIME=
LD_LIBRARY_PATH (unset)
LOGDIR (unset)

PATH=/usr/test/iridomcwa/scm/bin:/usr/prod/ecssitg/tools/main_bin:/usr/atria/bin:/usr/atria/etc:/home/shy/bin:/opt/local/bin:/opt/gnu/bin:/usr/bin:/usr/sbin:/usr/test/iridium/bin:/usr/mot/mstar/bin:/usr/mot/ifm/bin:/usr/mot/bin:/usr/ucb:/bin:/usr/vendor/bin:/usr/misc/bin:/etc:/usr/etc:/usr/mot/etc:/usr/lib:/usr/etc/yp:/usr/5bin:/usr/misc/elm/bin:/usr/vendor/TranScript/bin:/usr/test/tools/bin:/usr/test/tools/sun4/bin:/usr/bin/X11:/usr/test/emx500/bin:/usr/test/emx500/contrib/bin:/usr/test/bsstools/bin:/usr/test/bsstools/misc:/usr/test/gsmtesttools/bin:/usr/test/ecssitg/tools/bin:.:/usr/misc/X11/bin
PERLDB_OPTS=O ornaments='us,ue'
PERL_BADLANG (unset)
SHELL=/bin/tcsh

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupperl5-porters @
categoriesperl
postedJun 8, '00 at 6:23a
activeJun 8, '00 at 6:23a
posts1
users1
websiteperl.org

1 user in discussion

Richard Foley: 1 post

People

Translate

site design / logo © 2022 Grokbase