On Sun Jul 11 00:23:23 2010, greerga wrote:
> On Tue Mar 28 03:39:19 2000, tchrist@chthon.perl.com wrote:
> > From a CHECK{}, you cannot exit(0). You may exit !0, but not 0.
> > If you put this in /tmp/a and run it:
> >
> > #BEGIN { warn "testing exit from BEGIN"; exit }
> > #BEGIN { warn "testing exit N from BEGIN"; exit 1 }
> >
> > #INIT { warn "testing exit from INIT"; exit }
> > #INIT { warn "testing exit N from INIT"; exit 2 }
> >
> > CHECK { warn "testing exit from CHECK"; exit }
> > #CHECK { warn "testing exit N from CHECK"; exit 3 }
> >
> > #END { warn "testing exit from END"; exit }
> > #END { warn "testing exit N from END"; exit 4 }
> >
> > print "i am now the main program\n";
> > warn "testing exit 5 from main";
> > exit 5;
> >
> > die "XXX";
> >
> > You will get:
> >
> > % perl /tmp/a
> > testing exit from CHECK at /tmp/a line 7.
> > i am now the main program
> > testing exit 5 from main at /tmp/a line 14.
> > Exit 5
> >
> > If you switch the comment on the two CHECKs, you get
> >
> > % perl /tmp/a
> > testing exit N from CHECK at /tmp/a line 8.
> > Exit 3
>
> The problem (as of today's Perl) is that perl_parse() returns the exit
> status as if it were going back to the OS. In main(), perl does:
> "exitstatus = perl_parse(...); if (!exitstatus) perl_run(...);' Which
> means main() can't tell the difference between normal execution (0 from
> JMPENV) and my_exit (2 from JMPENV) because the my_exit case sets the
> return value to the exit code (0).
>
> perl_parse() is flagged as public API so my patch below is unacceptable
> although it does fix the immediate problem. I include it more as
> illustration than for inclusion (which is why it is a 'diff', not a
> 'commit'). It does, however, pass all tests which makes me think there
> should be tests that the public API is stable.
>
> I appeal to greater powers for a "public API"-acceptable fix. :)
I reappeal to greater powers for a "public API"-acceptable fix. Would be
nice to get this bug closed once and for all!
---
via perlbug: queue: perl5 status: open
https://rt.perl.org:443/rt3/Ticket/Display.html?id=2754
Thread Previous
|
Thread Next