scope(exit) and Ctrl-C
Wanderer
d-wanderer at hitbts.com
Sat Dec 2 00:41:19 UTC 2017
I wonder why `scope(exit)` code is not executed when the program
is terminated with Ctrl-C.
For example:
```
import std.stdio;
import core.thread;
void main()
{
scope (exit)
{
writeln("Cleanup");
}
writeln("Waiting...");
Thread.sleep(10.seconds);
writeln("Done waiting...");
}
```
If I wait 10 seconds, I get "Cleanup" output.
But if I use Ctrl-C to terminate the program before 10 seconds
elapse, there's no "Cleanup" output.
Is it intentional?
Is there any method to cleanup on Ctrl-C?
More information about the Digitalmars-d-learn
mailing list