Commit 12fa222c authored by Sam Lantinga's avatar Sam Lantinga

Use sigaction instead of signal to preserve handler flags (thanks Matthew!)

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40815
parent b2cf21a2
...@@ -763,6 +763,7 @@ CheckFBCON() ...@@ -763,6 +763,7 @@ CheckFBCON()
[ --enable-video-fbcon use framebuffer console video driver [default=yes]], [ --enable-video-fbcon use framebuffer console video driver [default=yes]],
, enable_video_fbcon=yes) , enable_video_fbcon=yes)
if test x$enable_video = xyes -a x$enable_video_fbcon = xyes; then if test x$enable_video = xyes -a x$enable_video_fbcon = xyes; then
CFLAGS="$CFLAGS -D__KERNEL_STRICT_NAMES"
AC_MSG_CHECKING(for framebuffer console support) AC_MSG_CHECKING(for framebuffer console support)
video_fbcon=no video_fbcon=no
AC_TRY_COMPILE([ AC_TRY_COMPILE([
...@@ -1387,6 +1388,31 @@ CopyUnixThreadSource() ...@@ -1387,6 +1388,31 @@ CopyUnixThreadSource()
fi fi
} }
dnl See if we can use sigaction() instead of signal()
CheckSIGACTION()
{
dnl Check for sigaction support
AC_ARG_ENABLE(sigaction,
[ --enable-sigaction use sigaction instead of signal [default=yes]],
, enable_sigaction=yes)
if test x$enable_sigaction = xyes; then
AC_MSG_CHECKING(sigaction)
have_sigaction=no
AC_TRY_COMPILE([
#include <signal.h>
],[
struct sigaction junk;
sigaction(0, &junk, &junk);
],[
have_sigaction=yes
])
AC_MSG_RESULT($have_sigaction)
if test x$have_sigaction = xyes; then
CFLAGS="$CFLAGS -DHAVE_SIGACTION"
fi
fi
}
dnl Determine whether the compiler can produce Win32 executables dnl Determine whether the compiler can produce Win32 executables
CheckWIN32() CheckWIN32()
{ {
...@@ -1775,6 +1801,7 @@ case "$target" in ...@@ -1775,6 +1801,7 @@ case "$target" in
CheckOpenGL CheckOpenGL
CheckInputEvents CheckInputEvents
CheckPTHREAD CheckPTHREAD
CheckSIGACTION
CheckAltivec CheckAltivec
# Set up files for the main() stub # Set up files for the main() stub
if test "x$video_qtopia" = "xyes"; then if test "x$video_qtopia" = "xyes"; then
...@@ -1851,6 +1878,7 @@ case "$target" in ...@@ -1851,6 +1878,7 @@ case "$target" in
CheckAAlib CheckAAlib
CheckOpenGL CheckOpenGL
CheckPTHREAD CheckPTHREAD
CheckSIGACTION
# Set up files for the audio library # Set up files for the audio library
# We use the OSS and ALSA API's, not the Sun audio API # We use the OSS and ALSA API's, not the Sun audio API
#if test x$enable_audio = xyes; then #if test x$enable_audio = xyes; then
...@@ -1895,6 +1923,7 @@ case "$target" in ...@@ -1895,6 +1923,7 @@ case "$target" in
CheckAAlib CheckAAlib
CheckOpenGL CheckOpenGL
CheckPTHREAD CheckPTHREAD
CheckSIGACTION
CheckUSBHID CheckUSBHID
# Set up files for the audio library # Set up files for the audio library
# We use the OSS and ALSA API's, not the Sun audio API # We use the OSS and ALSA API's, not the Sun audio API
...@@ -1931,6 +1960,7 @@ case "$target" in ...@@ -1931,6 +1960,7 @@ case "$target" in
CheckAAlib CheckAAlib
CheckOpenGL CheckOpenGL
CheckPTHREAD CheckPTHREAD
CheckSIGACTION
CheckUSBHID CheckUSBHID
# Set up files for the audio library # Set up files for the audio library
if test x$enable_audio = xyes; then if test x$enable_audio = xyes; then
...@@ -1971,6 +2001,7 @@ case "$target" in ...@@ -1971,6 +2001,7 @@ case "$target" in
CheckAAlib CheckAAlib
CheckOpenGL CheckOpenGL
CheckPTHREAD CheckPTHREAD
CheckSIGACTION
CheckUSBHID CheckUSBHID
# Set up files for the audio library # Set up files for the audio library
if test x$enable_audio = xyes; then if test x$enable_audio = xyes; then
...@@ -2012,6 +2043,7 @@ case "$target" in ...@@ -2012,6 +2043,7 @@ case "$target" in
CheckAAlib CheckAAlib
CheckOpenGL CheckOpenGL
CheckPTHREAD CheckPTHREAD
CheckSIGACTION
# Set up files for the audio library # Set up files for the audio library
if test x$enable_audio = xyes; then if test x$enable_audio = xyes; then
CFLAGS="$CFLAGS -DSUNAUDIO_SUPPORT" CFLAGS="$CFLAGS -DSUNAUDIO_SUPPORT"
...@@ -2053,6 +2085,7 @@ case "$target" in ...@@ -2053,6 +2085,7 @@ case "$target" in
CheckAAlib CheckAAlib
CheckOpenGL CheckOpenGL
CheckPTHREAD CheckPTHREAD
CheckSIGACTION
# Set up files for the audio library # Set up files for the audio library
if test x$enable_audio = xyes; then if test x$enable_audio = xyes; then
CFLAGS="$CFLAGS -DSUNAUDIO_SUPPORT" CFLAGS="$CFLAGS -DSUNAUDIO_SUPPORT"
...@@ -2091,6 +2124,7 @@ case "$target" in ...@@ -2091,6 +2124,7 @@ case "$target" in
CheckAAlib CheckAAlib
CheckOpenGL CheckOpenGL
CheckPTHREAD CheckPTHREAD
CheckSIGACTION
# We use the dmedia audio API, not the Sun audio API # We use the dmedia audio API, not the Sun audio API
#if test x$enable_audio = xyes; then #if test x$enable_audio = xyes; then
# CFLAGS="$CFLAGS -DSUNAUDIO_SUPPORT" # CFLAGS="$CFLAGS -DSUNAUDIO_SUPPORT"
...@@ -2141,6 +2175,7 @@ case "$target" in ...@@ -2141,6 +2175,7 @@ case "$target" in
CheckAAlib CheckAAlib
CheckOpenGL CheckOpenGL
CheckPTHREAD CheckPTHREAD
CheckSIGACTION
# Set up files for the audio library # Set up files for the audio library
if test x$enable_audio = xyes; then if test x$enable_audio = xyes; then
CFLAGS="$CFLAGS -DSUNAUDIO_SUPPORT" CFLAGS="$CFLAGS -DSUNAUDIO_SUPPORT"
...@@ -2180,6 +2215,7 @@ case "$target" in ...@@ -2180,6 +2215,7 @@ case "$target" in
CheckAAlib CheckAAlib
CheckOpenGL CheckOpenGL
CheckPTHREAD CheckPTHREAD
CheckSIGACTION
# Set up files for the audio library # Set up files for the audio library
if test x$enable_audio = xyes; then if test x$enable_audio = xyes; then
AUDIO_SUBDIRS="$AUDIO_SUBDIRS paudio" AUDIO_SUBDIRS="$AUDIO_SUBDIRS paudio"
...@@ -2216,6 +2252,7 @@ case "$target" in ...@@ -2216,6 +2252,7 @@ case "$target" in
CheckAAlib CheckAAlib
CheckOpenGL CheckOpenGL
CheckPTHREAD CheckPTHREAD
CheckSIGACTION
SDL_LIBS="$SDL_LIBS -lrt" SDL_LIBS="$SDL_LIBS -lrt"
# Set up files for the audio library # Set up files for the audio library
if test x$enable_audio = xyes; then if test x$enable_audio = xyes; then
...@@ -2255,6 +2292,7 @@ case "$target" in ...@@ -2255,6 +2292,7 @@ case "$target" in
CheckX11 CheckX11
CheckOpenGL CheckOpenGL
CheckPTHREAD CheckPTHREAD
CheckSIGACTION
# Set up files for the audio library # Set up files for the audio library
if test x$enable_audio = xyes; then if test x$enable_audio = xyes; then
CFLAGS="$CFLAGS -DQNXNTOAUDIO_SUPPORT" CFLAGS="$CFLAGS -DQNXNTOAUDIO_SUPPORT"
...@@ -2440,6 +2478,7 @@ case "$target" in ...@@ -2440,6 +2478,7 @@ case "$target" in
CheckQUARTZ CheckQUARTZ
CheckMacGL CheckMacGL
CheckPTHREAD CheckPTHREAD
CheckSIGACTION
# Set up files for the audio library # Set up files for the audio library
if test x$enable_audio = xyes; then if test x$enable_audio = xyes; then
AUDIO_SUBDIRS="$AUDIO_SUBDIRS macrom" AUDIO_SUBDIRS="$AUDIO_SUBDIRS macrom"
......
...@@ -127,47 +127,63 @@ static int SDL_fatal_signals[] = { ...@@ -127,47 +127,63 @@ static int SDL_fatal_signals[] = {
void SDL_InstallParachute(void) void SDL_InstallParachute(void)
{ {
/* Set a handler for any fatal signal not already handled */
int i; int i;
void (*ohandler)(int); #ifdef HAVE_SIGACTION
struct sigaction action;
/* Set a handler for any fatal signal not already handled */
for ( i=0; SDL_fatal_signals[i]; ++i ) { for ( i=0; SDL_fatal_signals[i]; ++i ) {
ohandler = signal(SDL_fatal_signals[i], SDL_Parachute); sigaction(SDL_fatal_signals[i], NULL, &action);
if ( ohandler != SIG_DFL ) { if ( action.sa_handler == SIG_DFL ) {
signal(SDL_fatal_signals[i], ohandler); action.sa_handler = SDL_Parachute;
sigaction(SDL_fatal_signals[i], &action, NULL);
} }
} }
#ifdef SIGALRM #ifdef SIGALRM
/* Set SIGALRM to be ignored -- necessary on Solaris */ /* Set SIGALRM to be ignored -- necessary on Solaris */
{ sigaction(SIGALRM, NULL, &action);
struct sigaction action, oaction; if ( action.sa_handler == SIG_DFL ) {
/* Set SIG_IGN action */
memset(&action, 0, (sizeof action));
action.sa_handler = SIG_IGN; action.sa_handler = SIG_IGN;
sigaction(SIGALRM, &action, &oaction); sigaction(SDL_fatal_signals[i], &action, NULL);
}
#endif
#else
void (*ohandler)(int);
/* Reset original action if it was already being handled */ for ( i=0; SDL_fatal_signals[i]; ++i ) {
if ( oaction.sa_handler != SIG_DFL ) { ohandler = signal(SDL_fatal_signals[i], SDL_Parachute);
sigaction(SIGALRM, &oaction, NULL); if ( ohandler != SIG_DFL ) {
signal(SDL_fatal_signals[i], ohandler);
} }
} }
#endif #endif /* HAVE_SIGACTION */
return; return;
} }
void SDL_UninstallParachute(void) void SDL_UninstallParachute(void)
{ {
/* Remove a handler for any fatal signal handled */
int i; int i;
#ifdef HAVE_SIGACTION
struct sigaction action;
for ( i=0; SDL_fatal_signals[i]; ++i ) {
sigaction(SDL_fatal_signals[i], NULL, &action);
if ( action.sa_handler == SDL_Parachute ) {
action.sa_handler = SIG_DFL;
sigaction(SDL_fatal_signals[i], &action, NULL);
}
}
#else
void (*ohandler)(int); void (*ohandler)(int);
/* Remove a handler for any fatal signal handled */
for ( i=0; SDL_fatal_signals[i]; ++i ) { for ( i=0; SDL_fatal_signals[i]; ++i ) {
ohandler = signal(SDL_fatal_signals[i], SIG_DFL); ohandler = signal(SDL_fatal_signals[i], SIG_DFL);
if ( ohandler != SDL_Parachute ) { if ( ohandler != SDL_Parachute ) {
signal(SDL_fatal_signals[i], ohandler); signal(SDL_fatal_signals[i], ohandler);
} }
} }
#endif /* HAVE_SIGACTION */
} }
#endif /* NO_SIGNAL_H */ #endif /* NO_SIGNAL_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment