develooper Front page | perl.perl5.porters | Postings from July 2019

[perl #127386] Setting $! during DESTROY clobbers exit value

From:
Nicolas R. via RT
Date:
July 31, 2019 04:22
Subject:
[perl #127386] Setting $! during DESTROY clobbers exit value
Message ID:
rt-4.0.24-26923-1564532764-1041.127386-15-0@perl.org
Note that as an extension this program will die with an exit code of 0...
Not really sure what would be the best way to localize $? and preserve a meaningful $? value
... not localizing it... of course avoid the issue

> perl -E '{ local $?; die "Boom!" }'; echo $?
Boom! at -e line 1.
0

On Tue, 23 Feb 2016 00:03:08 -0800, felipe@felipegasper.com wrote:
> On 22 Feb 2016 10:37 PM, Tony Cook via RT wrote:
> > On Mon Feb 08 15:22:16 2016, felipe@felipegasper.com wrote:
> >> Perhaps, then, modify the paragraph that begins the section to:
> >>
> >> -If an uncaught exception results in interpreter exit, the exit
> >> -code is determined from the values of $! and $? with this
> >> -pseudocode:
> >>
> >> +If L</die> is called when there is no L</eval> in the call stack,
> >> +Perl sets C<$?> as per the following pseudocode:
> >>
> >> Anyhow, if $? will continue to be set before propagation rather than
> >> after, then this is kind of splitting hairs. I definitely appreciate
> >> Tony’s proposed change.
> >
> > I thought about that, and tried a few variations on the text, but
> > didn't
> > come up with any changes I liked.
> >
> > I've applied my most recent patch with a change from a comma to a
> > semi-colon as 88aeef83d79fbcd4dab43cc58155923e65a6d82e.
> >
> 
> Thank you! :)
> 
> -FG



---
via perlbug:  queue: perl5 status: resolved
https://rt.perl.org/Ticket/Display.html?id=127386



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About