From c636332031b530d5c8cd79569d76f4fe7ed53f0c Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Mon, 1 Dec 2025 17:31:55 -0600 Subject: [PATCH] quit: don't call signal() if we're using sigaction() At best, this is a no-op. At worst, it might: - Clobber a signal handler someone registered after us - Overwrite the signal mask or flags - Cause unregistration to fail (sigaction() isn't guaranteed to return the exact pointer passed to signal()) (cherry picked from commit 1d852d1c2872ec4275505e10e0e02392c0d60405) --- src/events/SDL_quit.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/events/SDL_quit.c b/src/events/SDL_quit.c index b4234fc218..dcf722645c 100644 --- a/src/events/SDL_quit.c +++ b/src/events/SDL_quit.c @@ -49,8 +49,10 @@ static SDL_bool send_foregrounding_pending = SDL_FALSE; static void SDL_HandleSIG(int sig) { - /* Reset the signal handler */ +#ifndef HAVE_SIGACTION + /* Reset the signal handler if it was installed with signal() */ (void)signal(sig, SDL_HandleSIG); +#endif /* Send a quit event next time the event loop pumps. */ /* We can't send it in signal handler; SDL_malloc() might be interrupted! */