🦋 Welcome to the IRC channel of the core developers of the Raku Programming Language (raku.org #rakulang). This channel is logged for the purpose of history keeping about its development | evalbot usage: 'm: say 3;' or /msg camelia m: ... | Logs available at irclogs.raku.org/raku-dev/live.html | For MoarVM see #moarvm
Set by lizmat on 8 June 2022.
Geth rakudo/lizmat-died-naturally: 072d961bb3 | (Elizabeth Mattijsen)++ | src/main.nqp
Set $*DIED-NATURALLY if exiting program without exception

Inspired by stackoverflow.com/questions/730405...gramm-died
This minimal change allows an END block to do special actions if the program exited because of an exception:
... (5 more lines)
17:02
rakudo: lizmat++ created pull request #4988:
Set $*DIED-NATURALLY if exiting program without exception
gfldex lizmat: does `exit(1)` inside an END-phaser do the right thing? 19:02
lizmat I believe so? 19:03
m: END { exit(1) } 19:04
camelia ( no output )
lizmat m: END { say "last END" }; END { exit(1) }
camelia last END
lizmat m: END { say "not last END" }; END { exit(1) }; END { say "last end" }
camelia last end
not last END
lizmat hmmm
ah, I remember... if you're basically inside the exit handler, "exit" becomes a noop ? 19:05
m: END { say "not last END" }; END { exit(1); say "after exit" }; END { say "last end" }
camelia last end
not last END
lizmat but only for the END block in which you exit
m: END { say "last END" }; END { exit(1); say "after exit" }; END { say "not last end" } 19:06
camelia not last end
last END
lizmat and in reverse order
m: END { say "last END" }; END { say "before exit"; exit(1); say "after exit" }; END { say "not last end" }
camelia not last end
before exit
last END
gfldex From a sysadmin standpoint I don't like END at all. It is very tempting to believe the core will be run. And then some native lib segfaults or you hit an OOM-condition. 19:08
lizmat well, there's that of course... I guess at some point we could think about catching segfaults in a meaningful way
lizmat and aren't OOM's handled by a "kill" first? That should run END, shouldn't it ? 19:09
lizmat unless it's a kill -9 f course 19:09
gfldex And that's why setting the exit-code is important. We typically deal with abnormal termination with a shell wrapper. That `exit` may not do what you expect it to, is at least an ENODOC. 19:11
gfldex m: my atomicint $i; my @proms; for ^20 { @proms.push: start { exit ++⚛$i; } }; await @proms; 19:18
camelia ( no output )
gfldex ^^^ poor way to implement a RNG :)
lizmat gfldex: the first thread issuing exit() determines the final exit value
any other exit values are ignored 19:19
gfldex because of the state container in exit
lizmat that seemed to be the most sensible way of dealing with multiple threads doing an exit()
rught
*right
gfldex ENODOC issed as #4097 19:25