Fix signal handler issues

Thanks Alug! f4dc161831 e35dc9e097 2f684bba95
This commit is contained in:
NepDisk 2026-02-24 12:40:48 -05:00
parent 80db0bde07
commit 76a08efd78
5 changed files with 22 additions and 9 deletions

View file

@ -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()

View file

@ -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

View file

@ -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)

View file

@ -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

View file

@ -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;
}