On 21 Jul 2014, at 09:25, Carl Mäsak (via RT) <perl6-bugs-follo...@perl.org> 
wrote:
> # New Ticket Created by  "Carl Mäsak" 
> # Please include the string:  [perl #122355]
> # in the subject line of all future correspondence about this issue. 
> # <URL: https://rt.perl.org/Ticket/Display.html?id=122355 >
> 
> 
> <hoelzro> in Perl 5, one can assign to $? in an END block to alter a
> program's exit status.  Is there an analogous construct in Perl 6?
> <masak> hoelzro: `exit($status);`
> <masak> hm, `END exit(5)` hangs locally.
> <hoelzro> masak: that's what I tried, and also discovered =)
> <masak> r: END exit(5)
> <camelia> rakudo-{parrot,moar} e56d94: OUTPUT«(timeout)»
> <camelia> ..rakudo-jvm e56d94: OUTPUT«(timeout)Unhandled exception:
> java.lang.StackOverflowError [...]
> * masak submits rakudobug
> 
> Moar and Parrot loop forever; the JVM blows the call stack. My guess
> is that a call to &exit tries to run all the registered END blocks or
> something.
> 
> I don't recall the spec mentioning this, but it feels fairly obvious
> to me that we should support calling &exit from an END block, and that
> it should Just Work. We probably should have wording in S32 to that
> effect.

FWIW, I think the problem is that running the END blocks does not remove them 
from the list of END blocks.

Each END block should only be run *once*.  Hence, execution of an END block 
should remove it from the list *before* executing it.

Pretty sure that would solve this problem.



Liz

Reply via email to