mirror of
https://github.com/VincentWei/MiniGUI.git
synced 2026-09-24 00:54:18 +08:00
handle SIGINT
This commit is contained in:
+9
-14
@@ -248,36 +248,31 @@ 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) {
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
+9
-4
@@ -321,9 +321,14 @@ static void sig_handler (int v)
|
||||
{
|
||||
if (v == SIGSEGV) {
|
||||
kill (getpid(), SIGABRT); /* cause core dump */
|
||||
}else if (__mg_quiting_stage > 0) {
|
||||
}
|
||||
else if (v == SIGINT) {
|
||||
_exit(1);
|
||||
}
|
||||
else if (__mg_quiting_stage > 0) {
|
||||
ExitGUISafely(-1);
|
||||
}else{
|
||||
}
|
||||
else {
|
||||
exit(1); /* force to quit */
|
||||
}
|
||||
}
|
||||
@@ -331,10 +336,10 @@ static void sig_handler (int v)
|
||||
static BOOL InstallSEGVHandler (void)
|
||||
{
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user