How to execute cleanup code on Ctrl-C (Break)?
Paul Dufresne
dufresnep at gmail.com
Sun Jul 8 19:15:08 PDT 2012
Well, I just want to close a socket before quiting if the user
press Ctrl-C.
That said, looking through the code, I would say that it have no
implementation for Windows... even if it should have signals.
And even there, I do not really understand how I am suppose to
use it.
I think it should looks like:
import std.stdio;
import core.sys.posix.signal;
void mybye(int value){
writeln("oh... Bye then!");
}
void main(){
sigset(SIGINT, &mybye);
while (true) writeln("H1!!");
}
which gives me:
C:\Users\Paul\myd>dmd loop2.d
loop2.d(9): Error: undefined identifier sigset
Which I guess is because there is no Windows implementation...
yet.
More information about the Digitalmars-d-learn
mailing list