diff --git a/src/console.c b/src/console.c index 8039ff888..c89f8124b 100644 --- a/src/console.c +++ b/src/console.c @@ -47,12 +47,12 @@ #ifdef HAVE_THREADS I_mutex con_mutex; -// g_in_exiting_signal_handler is an evil hack +// I_In_Exiting_Signal_Handler is an evil hack // to avoid infinite SIGABRT recursion in the signal handler // due to poisoned locks or mach-o kernel not supporting locks in signals // or something like that. idk -# define Lock_state() if (!g_in_exiting_signal_handler) { I_lock_mutex(&con_mutex); } -# define Unlock_state() if (!g_in_exiting_signal_handler) { I_unlock_mutex(con_mutex); } +# define Lock_state() if (!I_In_Exiting_Signal_Handler) { I_lock_mutex(&con_mutex); } +# define Unlock_state() if (!I_In_Exiting_Signal_Handler) { I_unlock_mutex(con_mutex); } #else/*HAVE_THREADS*/ # define Lock_state() # define Unlock_state() diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 868967d82..859313833 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -2100,6 +2100,11 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic // Call it only once by tic if (*oldtic != I_GetTime()) { + if (I_Interrupted()) + { + I_Quit(); + } + I_OsPolling(); // Needs to be updated here for M_DrawEggaChannel diff --git a/src/d_main.cpp b/src/d_main.cpp index 896a18714..0362fddb7 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -879,6 +879,11 @@ void D_WipeLoop(wipelooptype_t type, UINT8 wipetype, boolean drawMenu) #ifndef NOWIPE if (type == WIPELOOP_RUNWIPE) { + if (I_Interrupted()) + { + I_Quit(); + } + // get fademask first so we can tell if it exists or not fmask = F_GetFadeMask(wipetype, wipeframe); if (!fmask) diff --git a/src/i_system.h b/src/i_system.h index 076a62101..b65477609 100644 --- a/src/i_system.h +++ b/src/i_system.h @@ -35,7 +35,7 @@ extern UINT8 graphics_started; extern UINT8 keyboard_started; /** \brief Set to true when inside a signal handler that will exit the program. */ -extern boolean g_in_exiting_signal_handler; +boolean I_In_Exiting_Signal_Handler(void); /** \brief The I_GetFreeMem function diff --git a/src/sdl/i_system.cpp b/src/sdl/i_system.cpp index 31072e41d..1363e3b94 100644 --- a/src/sdl/i_system.cpp +++ b/src/sdl/i_system.cpp @@ -220,7 +220,7 @@ bool consolevent = false; bool framebuffer = false; UINT8 keyboard_started = false; -boolean g_in_exiting_signal_handler = false; +static volatile sig_atomic_t g_in_exiting_signal_handler = false; #ifdef UNIXBACKTRACE #define STDERR_WRITE(string) if (fd != -1) I_OutputMsg("%s", string) @@ -428,6 +428,11 @@ static void I_ReportSignal(int num, int coredumped) ); } +boolean I_In_Exiting_Signal_Handler(void) +{ + return g_in_exiting_signal_handler; +} + #ifndef NEWSIGNALHANDLER static ATTRNORETURN void signal_handler(INT32 num) { @@ -452,7 +457,7 @@ static ATTRNORETURN void signal_handler(INT32 num) } #endif -static volatile sig_atomic_t interrupted = 0; +static volatile sig_atomic_t interrupted = false; boolean I_Interrupted(void) { @@ -461,9 +466,7 @@ boolean I_Interrupted(void) static void quit_handler(int num) { - signal(num, SIG_DFL); //default signal action - raise(num); - //I_Quit(); + (void)num; interrupted = true; }