Просмотр исходного кода

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 6d99204a829879a3dbe975c6158228d07bfc1a0d)
Cameron Gutman 3 месяцев назад
Родитель
Сommit
80f82acdf8
1 измененных файлов с 3 добавлено и 1 удалено
  1. 3 1
      src/events/SDL_quit.c

+ 3 - 1
src/events/SDL_quit.c

@@ -46,8 +46,10 @@ static bool send_foregrounding_pending = false;
 
 
 static void SDL_HandleSIG(int sig)
 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);
     (void)signal(sig, SDL_HandleSIG);
+#endif
 
 
     // Send a quit event next time the event loop pumps.
     // Send a quit event next time the event loop pumps.
     // We can't send it in signal handler; SDL_malloc() might be interrupted!
     // We can't send it in signal handler; SDL_malloc() might be interrupted!