scope(exit) and Ctrl-C
Wanderer
d-wanderer at hitbts.com
Sat Dec 2 04:20:44 UTC 2017
On Saturday, 2 December 2017 at 01:26:14 UTC, Adam D. Ruppe wrote:
> On Saturday, 2 December 2017 at 00:41:19 UTC, Wanderer wrote:
>> I wonder why `scope(exit)` code is not executed when the
>> program is terminated with Ctrl-C.
>
> It depends on what your operating system is. On win32, I
> believe it does run. On Linux (and I think Mac) you need to set
> a signal handler to catch the ctrl c.
>
> But this is intentional - there is no generic, reliable,
> cross-platform way of handling it natively. So you need to know
> the system and code it yourself. Not super hard but does take a
> bit of effort in your code.
On Windows 10 it does not run.
Thanks for the info, I dig around and truly there's no "general"
way to do this.
More information about the Digitalmars-d-learn
mailing list