handle SIGINT for ths and sa runmodes

This commit is contained in:
Vincent Wei
2019-04-06 13:59:13 +08:00
parent 32d800b1b9
commit 36e3869385

View File

@@ -255,36 +255,32 @@ failure:
static void sig_handler (int v)
{
if (v == SIGSEGV) {
#ifdef WIN32
raise(SIGABRT);
#else
kill (getpid(), SIGABRT); /* cause core dump */
#endif
}else if (__mg_quiting_stage > 0) {
}
else if (v == SIGINT) {
_exit(1); /* force to quit */
}
else if (__mg_quiting_stage > 0) {
ExitGUISafely(-1);
}else{
}
else {
exit(1); /* force to quit */
}
}
static BOOL InstallSEGVHandler (void)
{
#ifdef WIN32
signal(SIGSEGV, sig_handler);
signal(SIGTERM, sig_handler);
signal(SIGINT, sig_handler);
#else
struct sigaction siga;
siga.sa_handler = sig_handler;
siga.sa_flags = 0;
memset (&siga.sa_mask, 0, sizeof (sigset_t));
sigaction (SIGSEGV, &siga, NULL);
sigaction (SIGTERM, &siga, NULL);
sigaction (SIGINT, &siga, NULL);
sigaction (SIGPIPE, &siga, NULL);
#endif
return TRUE;
}