If application installs SIGINT/SIGTERM signal handler with
sigaction(SA_SIGINFO) syscall before initializing SDL, after
initialization
of SDL signal handler will be reinstalled without SA_SIGINFO flag which
brings havoc when the signal handler is called. The breakage is done by
SDL_QuitInit()/SDL_QuitQuit() function. They use signal() to detect that
signal handler is already installed even in sigaction() is available.
Attached are two patches for sdl-1.2 and sdl-1.3 to solve this problem–
Gleb.
-------------- next part --------------
diff -r 67d3be4ec9f2 src/events/SDL_quit.c
— a/src/events/SDL_quit.c Thu Feb 24 17:42:45 2011 -0800
+++ b/src/events/SDL_quit.c Mon Mar 14 13:56:03 2011 +0200
@@ -45,7 +45,19 @@
/* Public functions */
int SDL_QuitInit(void)
{
-#ifdef HAVE_SIGNAL_H
+#ifdef HAVE_SIGACTION
-
struct sigaction action;
-
sigaction(SIGINT, NULL, &action);
-
if ( action.sa_handler == SIG_DFL && action.sa_sigaction == SIG_DFL ) {
-
action.sa_handler = SDL_HandleSIG;
-
sigaction(SIGINT, &action, NULL);
-
}
-
sigaction(SIGTERM, NULL, &action);
-
if ( action.sa_handler == SIG_DFL && action.sa_sigaction == SIG_DFL ) {
-
action.sa_handler = SDL_HandleSIG;
-
sigaction(SIGTERM, &action, NULL);
-
}
+#elif HAVE_SIGNAL_H
void (*ohandler)(int);/* Both SIGINT and SIGTERM are translated into quit interrupts */
@@ -62,7 +74,19 @@
}
void SDL_QuitQuit(void)
{
-#ifdef HAVE_SIGNAL_H
+#ifdef HAVE_SIGACTION -
struct sigaction action;
-
sigaction(SIGINT, NULL, &action);
-
if ( action.sa_handler == SDL_HandleSIG ) {
-
action.sa_handler = SIG_DFL;
-
sigaction(SIGINT, &action, NULL);
-
}
-
sigaction(SIGTERM, NULL, &action);
-
if ( action.sa_handler == SDL_HandleSIG ) {
-
action.sa_handler = SIG_DFL;
-
sigaction(SIGTERM, &action, NULL);
-
}
+#elif HAVE_SIGNAL_H
void (*ohandler)(int);ohandler = signal(SIGINT, SIG_DFL);
-------------- next part --------------
diff -r 4cf1ad60ad47 src/events/SDL_quit.c
— a/src/events/SDL_quit.c Sun Mar 13 19:06:43 2011 -0700
+++ b/src/events/SDL_quit.c Mon Mar 14 13:56:00 2011 +0200
@@ -47,7 +47,19 @@
int
SDL_QuitInit(void)
{
-#ifdef HAVE_SIGNAL_H
+#ifdef HAVE_SIGACTION -
struct sigaction action;
-
sigaction(SIGINT, NULL, &action);
-
if ( action.sa_handler == SIG_DFL && action.sa_sigaction == SIG_DFL ) {
-
action.sa_handler = SDL_HandleSIG;
-
sigaction(SIGINT, &action, NULL);
-
}
-
sigaction(SIGTERM, NULL, &action);
-
if ( action.sa_handler == SIG_DFL && action.sa_sigaction == SIG_DFL ) {
-
action.sa_handler = SDL_HandleSIG;
-
sigaction(SIGTERM, &action, NULL);
-
}
+#elif HAVE_SIGNAL_H
void (*ohandler) (int);/* Both SIGINT and SIGTERM are translated into quit interrupts */
@@ -66,7 +78,19 @@
void
SDL_QuitQuit(void)
{
-#ifdef HAVE_SIGNAL_H
+#ifdef HAVE_SIGACTION -
struct sigaction action;
-
sigaction(SIGINT, NULL, &action);
-
if ( action.sa_handler == SDL_HandleSIG ) {
-
action.sa_handler = SIG_DFL;
-
sigaction(SIGINT, &action, NULL);
-
}
-
sigaction(SIGTERM, NULL, &action);
-
if ( action.sa_handler == SDL_HandleSIG ) {
-
action.sa_handler = SIG_DFL;
-
sigaction(SIGTERM, &action, NULL);
-
}
+#elif HAVE_SIGNAL_H
void (*ohandler) (int);ohandler = signal(SIGINT, SIG_DFL);