Throw stack trace from program kill
Paul Backus
snarwin at gmail.com
Sun Jan 16 18:33:21 UTC 2022
On Sunday, 16 January 2022 at 18:22:04 UTC, Steven Schveighoffer
wrote:
>
> Does this work normally? The memory error handler for Linux
> jumps through a lot of hoops to be able to throw an error from
> a signal handler. See
> https://github.com/dlang/druntime/blob/master/src/etc/linux/memoryerror.d
It worked when I tested it, but I'm not sure how reliable it is.
A more conservative implementation would be something like
```d
extern(C) void handleCtrlC(int)
{
import core.stdc.stdlib: exit;
import std.stdio: writeln;
try throw new Exception("Killed by CTRL+C");
catch (Exception e)
{
writeln(e.message);
writeln(e.info);
exit(1);
}
}
```
More information about the Digitalmars-d-learn
mailing list