exit handler fix (for linux)

master
Thomas Baumbach 2013-09-11 21:42:26 +02:00
parent 161b3da53a
commit 8e99df10bc
1 changed files with 12 additions and 4 deletions

View File

@ -6,6 +6,8 @@
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstdlib>
#include <csignal>
#include <map>
#include "prime.h"
@ -415,10 +417,8 @@ void exit_handler() {
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <cstdlib>
#include <csignal>
BOOL WINAPI handler(DWORD dwCtrlType) {
BOOL WINAPI ctrl_handler(DWORD dwCtrlType) {
//'special' cleanup for windows
switch(dwCtrlType) {
case CTRL_C_EVENT:
@ -435,6 +435,12 @@ BOOL WINAPI handler(DWORD dwCtrlType) {
return FALSE;
}
#else
void ctrl_handler(sig_t s) {
exit(1);
}
#endif
/*********************************
@ -454,7 +460,9 @@ int main(int argc, char **argv)
running = true;
#ifdef __MINGW32__
SetConsoleCtrlHandler(handler, TRUE);
SetConsoleCtrlHandler(ctrl_handler, TRUE);
#else
signal(SIGINT, ctrl_handler);
#endif
if (argc < 2)