Fix signal handler issues
Thanks Alug!f4dc161831e35dc9e0972f684bba95
This commit is contained in:
parent
80db0bde07
commit
76a08efd78
5 changed files with 22 additions and 9 deletions
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue