Okay, I am writing a program that is doing some pretty heavy analysis and I would like to be able to stop it quickly.
I added signal(SIGINT, terminate);
to
From MSDN:
Note SIGINT is not supported for any Win32 application, including Windows 98/Me and Windows NT/2000/XP. When a CTRL+C interrupt occurs, Win32 operating systems generate a new thread to specifically handle that interrupt. This can cause a single-thread application such as UNIX, to become multithreaded, resulting in unexpected behavior.
Which means you will have to use preprocessing directive and implement a Windows specific solution.
BOOL WINAPI handler(DWORD dwCtrlType)
{
if (CTRL_C_EVENT == dwCtrlType)
{
// ask the user
}
return FALSE;
}
And at the beginning of main
you do
SetConsoleCtrlHandler(handler, TRUE);