dont call I_Quit from within "quit_handler", let it signal main loop to quit

fixes an issue for me which led to having the game threads getting stuck when sending an interrupt signal to the game due to some thread issues with the sdl subsystems

shoutout to dsda doom for this
This commit is contained in:
Alug committed 2025-12-07 20:27:57 +01:00
1 parent 3cb4e86b48
commit a2feaa7fde
6 files changed
+29 -17

No files matched your search

+3
View File
@@ -679,6 +679,9 @@ void D_SRB2Loop(void)
for (;;)
{
if (I_Interrupted())
I_Quit();
// capbudget is the minimum precise_t duration of a single loop iteration
precise_t capbudget;
precise_t elapsed;
+10 -2
View File
@@ -1075,11 +1075,19 @@ FUNCNORETURN static ATTRNORETURN void signal_handler(INT32 num)
}
#endif
FUNCNORETURN static ATTRNORETURN void quit_handler(int num)
static volatile sig_atomic_t interrupted = 0;
boolean I_Interrupted(void)
{
return interrupted;
}
static void quit_handler(int num)
{
signal(num, SIG_DFL); //default signal action
raise(num);
I_Quit();
//I_Quit();
interrupted = true;
}
#ifdef HAVE_LIBBACKTRACE
+2 -1
View File
@@ -29,7 +29,6 @@ extern "C" {
*/
#define MAX_QUIT_FUNCS 16
/** \brief Graphic system had started up
*/
extern UINT8 graphics_started;
@@ -191,6 +190,8 @@ INT32 I_StartupSystem(void);
*/
void I_ShutdownSystem(void);
boolean I_Interrupted(void);
/** \brief The I_GetDiskFreeSpace function
\param freespace a INT64 pointer to hold the free space amount
+10 -12
View File
@@ -1670,21 +1670,19 @@ FUNCNORETURN static ATTRNORETURN void signal_handler(INT32 num)
}
#endif
FUNCNORETURN static ATTRNORETURN void quit_handler(int num)
{
#ifdef HAVE_THREADS
if (g_main_thread_id != std::this_thread::get_id())
{
// Do not attempt any sort of recovery if this signal triggers off the main thread
signal(num, SIG_DFL);
raise(num);
exit(-2);
}
#endif
static volatile sig_atomic_t interrupted = 0;
boolean I_Interrupted(void)
{
return interrupted;
}
static void quit_handler(int num)
{
signal(num, SIG_DFL); //default signal action
raise(num);
I_Quit();
//I_Quit();
interrupted = true;
}
static void I_RegisterSignals(void)
+2 -1
View File
@@ -2012,7 +2012,8 @@ void I_ShutdownGraphics(void)
SDL_DestroyWindow(window);
window = NULL;
SDL_QuitSubSystem(SDL_INIT_VIDEO);
if (SDL_WasInit(SDL_INIT_VIDEO) == SDL_INIT_VIDEO)
SDL_QuitSubSystem(SDL_INIT_VIDEO);
framebuffer = SDL_FALSE;
}
+2 -1
View File
@@ -237,7 +237,8 @@ void I_ShutdownSound(void)
Mix_Quit();
#endif
SDL_QuitSubSystem(SDL_INIT_AUDIO);
if (SDL_WasInit(SDL_INIT_AUDIO) == SDL_INIT_AUDIO)
SDL_QuitSubSystem(SDL_INIT_AUDIO);
#ifdef HAVE_LIBGME
if (gme)