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
system/fork in DESTROY overrides exit code of parent program #7371
Comments
From xiaoke@cup.hp.comThis is a bug report for perl from xiaoke@cup.hp.com, Hi, It seems there is a problem with exit codes and DESTORY method of an After tinkering around with this. It seems if the DESTROY method in an Here is an example: package T; sub new { sub DESTROY { 1; print "Bluh bluh bluh\n"; It doesn't matter what exit code is at the bottom, the script always exits # ./test.pl ; echo $? As if the exit code 0 from system("date") is overriding the "exit 3" in I don't know if this is a feature or a bug, please advise. Thanks. xiaoke(at)cup(dot)hp(dot)com Flags: This perlbug was built using Perl v5.8.0 - Wed Apr 2 21:15:30 UTC 2003 Site configuration information for perl v5.8.0: Configured by root at Wed Apr 2 21:06:22 UTC 2003. Summary of my perl5 (revision 5.0 version 8 subversion 0) configuration: Locally applied patches: @INC for perl v5.8.0: Environment for perl v5.8.0: |
From @iabynOn Thu, Jun 17, 2004 at 07:16:52AM -0000, Xiaoke Zhang wrote:
It's (mostly) a feature. From 'man perlvar': Inside an C<END> subroutine C<$?> contains the value that is going to be END { Admittedly you're setting $? inside a destructor called at the end of the Dave. -- |
The RT System itself - Status changed from 'new' to 'open' |
From @ysthOn Thu, Jun 17, 2004 at 11:38:26PM +0100, Dave Mitchell <davem@iabyn.com> wrote:
How does this look? (No, I haven't actually verified that local $? helps.) Inline Patch--- perl/pod/perlvar.pod.orig 2004-02-03 12:00:30.000000000 -0800
+++ perl/pod/perlvar.pod 2004-06-17 17:31:10.930244800 -0700
@@ -629,14 +629,18 @@ is returned via $? if any C<gethost*()>
If you have installed a signal handler for C<SIGCHLD>, the
value of C<$?> will usually be wrong outside that handler.
-Inside an C<END> subroutine C<$?> contains the value that is going to be
-given to C<exit()>. You can modify C<$?> in an C<END> subroutine to
-change the exit status of your program. For example:
+Inside an C<END> subroutine, or a C<DESTROY> method called while
+exiting, C<$?> contains the value that is going to be given to
+C<exit()>. You can modify C<$?> in an C<END> subroutine to change the
+exit status of your program. For example:
END {
$? = 1 if $? == 255; # die would make it 255
}
+Even indirect setting of $? (e.g. by calling C<system> or C<fork>)
+will have this effect. If this is not intended, localize $?.
+
Under VMS, the pragma C<use vmsish 'status'> makes C<$?> reflect the
actual VMS exit status, instead of the default emulation of POSIX
status; see L<perlvms/$?> for details.
End of Patch. |
From xiaoke@cup.hp.comThanks for your help. I am going to get the $? in the begining of Thanks for prompt response. xz On Fri, 18 Jun 2004, Yitzchak Scott-Thoennes via RT wrote:
|
From perl5-porters@ton.iguana.beIn article <20040618172727.GB3864@e_n.org>,
I'd rather see it fixed than documented. Conceptually you don't Isn't it possible to find a place between END block processing and Even if not, documenting it would make it official, and I really can't |
From @hvdsperl5-porters@ton.iguana.be (Ton Hospel) wrote: Then you should read the documentation, and adjust your concepts - :Being sure that all It is rare that a DESTROY method does anything that might affect $?. It therefore seems perfectly reasonable to me to document this Hugo |
@iabyn - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#30331 (status was 'resolved')
Searchable as RT30331$
The text was updated successfully, but these errors were encountered: