Below is my code to run on win32.
#include "stdafx.h"
#include <signal.h>
void INThandler( int sig )
{
printf( "Ctrl-C pressed\n" );
}
int main ()
{
signal( SIGINT, INThandler );
while (1)
{
}
return 0;
}
The output of the program is as follows after I press ctrl-c twice.
Exception thrown at 0x76707577 (kernel32.dll) in test.exe: 0x40010005: Control-C.
The thread 0x6a8 has exited with code 0 (0x0).
Exception thrown at 0x76707577 (kernel32.dll) in test.exe: 0x40010005: Control-C.
The thread 0x4104 has exited with code -1073741510 (0xc000013a).
The program '[14580] test.exe' has exited with code -1073741510 (0xc000013a).
My question is: why my second ctrl-c can't be captured by my signal processing function? How should I process this kind of issues?
I have this problem since my real program takes a lot of resource and it takes a long time to release those resource. So if the release process has not been done while the 2nd ctrl-c comes, some errors (memory leak) will be generated. I want to avoid this.