src/events/SDL_quit.c
changeset 9434 0a695c9c3c71
parent 8149 681eb46b8ac4
child 9435 0979c3e31211
     1.1 --- a/src/events/SDL_quit.c	Tue Mar 24 13:52:01 2015 -0400
     1.2 +++ b/src/events/SDL_quit.c	Tue Mar 24 14:29:25 2015 -0400
     1.3 @@ -19,6 +19,7 @@
     1.4    3. This notice may not be removed or altered from any source distribution.
     1.5  */
     1.6  #include "../SDL_internal.h"
     1.7 +#include "SDL_hints.h"
     1.8  
     1.9  /* General quit handling code for SDL */
    1.10  
    1.11 @@ -30,6 +31,8 @@
    1.12  #include "SDL_events_c.h"
    1.13  
    1.14  
    1.15 +static SDL_bool disable_signals = SDL_FALSE;
    1.16 +
    1.17  #ifdef HAVE_SIGNAL_H
    1.18  static void
    1.19  SDL_HandleSIG(int sig)
    1.20 @@ -46,6 +49,12 @@
    1.21  int
    1.22  SDL_QuitInit(void)
    1.23  {
    1.24 +    const char *hint = SDL_GetHint(SDL_HINT_DISABLE_SIGINT_HANDLER);
    1.25 +    disable_signals = hint && (SDL_atoi(hint) == 1);
    1.26 +    if (disable_signals) {
    1.27 +        return 0;
    1.28 +    }
    1.29 +
    1.30  #ifdef HAVE_SIGACTION
    1.31      struct sigaction action;
    1.32      sigaction(SIGINT, NULL, &action);
    1.33 @@ -80,12 +89,16 @@
    1.34  #endif /* HAVE_SIGNAL_H */
    1.35  
    1.36      /* That's it! */
    1.37 -    return (0);
    1.38 +    return 0;
    1.39  }
    1.40  
    1.41  void
    1.42  SDL_QuitQuit(void)
    1.43  {
    1.44 +    if (disable_signals) {
    1.45 +        return;
    1.46 +    }
    1.47 +
    1.48  #ifdef HAVE_SIGACTION
    1.49      struct sigaction action;
    1.50      sigaction(SIGINT, NULL, &action);