SDL  2.0
SDL_quit.c File Reference
#include "../SDL_internal.h"
#include "SDL_hints.h"
#include "SDL_assert.h"
#include "SDL_events.h"
#include "SDL_events_c.h"
+ Include dependency graph for SDL_quit.c:

Go to the source code of this file.

Functions

static void SDL_HandleSIG (int sig)
static int SDL_QuitInit_Internal (void)
int SDL_QuitInit (void)
static void SDL_QuitQuit_Internal (void)
void SDL_QuitQuit (void)
int SDL_SendQuit (void)
void SDL_SendPendingQuit (void)

Variables

static SDL_bool disable_signals = SDL_FALSE
static SDL_bool send_quit_pending = SDL_FALSE

Function Documentation

static void SDL_HandleSIG ( int  sig)
static

Definition at line 39 of file SDL_quit.c.

References SDL_TRUE, and send_quit_pending.

Referenced by SDL_QuitInit_Internal(), and SDL_QuitQuit_Internal().

{
/* Reset the signal handler */
signal(sig, SDL_HandleSIG);
/* Send a quit event next time the event loop pumps. */
/* We can't send it in signal handler; malloc() might be interrupted! */
}
int SDL_QuitInit ( void  )
static int SDL_QuitInit_Internal ( void  )
static

Definition at line 52 of file SDL_quit.c.

References NULL, SDL_HandleSIG(), and void.

Referenced by SDL_QuitInit().

{
#ifdef HAVE_SIGACTION
struct sigaction action;
sigaction(SIGINT, NULL, &action);
#ifdef HAVE_SA_SIGACTION
if ( action.sa_handler == SIG_DFL && (void (*)(int))action.sa_sigaction == SIG_DFL ) {
#else
if ( action.sa_handler == SIG_DFL ) {
#endif
action.sa_handler = SDL_HandleSIG;
sigaction(SIGINT, &action, NULL);
}
sigaction(SIGTERM, NULL, &action);
#ifdef HAVE_SA_SIGACTION
if ( action.sa_handler == SIG_DFL && (void (*)(int))action.sa_sigaction == SIG_DFL ) {
#else
if ( action.sa_handler == SIG_DFL ) {
#endif
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 */
ohandler = signal(SIGINT, SDL_HandleSIG);
if (ohandler != SIG_DFL)
signal(SIGINT, ohandler);
ohandler = signal(SIGTERM, SDL_HandleSIG);
if (ohandler != SIG_DFL)
signal(SIGTERM, ohandler);
#endif /* HAVE_SIGNAL_H */
/* That's it! */
return 0;
}
void SDL_QuitQuit ( void  )

Definition at line 128 of file SDL_quit.c.

References disable_signals, and SDL_QuitQuit_Internal().

Referenced by SDL_QuitSubSystem().

static void SDL_QuitQuit_Internal ( void  )
static

Definition at line 101 of file SDL_quit.c.

References NULL, SDL_HandleSIG(), and void.

Referenced by SDL_QuitQuit().

{
#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);
if (ohandler != SDL_HandleSIG)
signal(SIGINT, ohandler);
ohandler = signal(SIGTERM, SIG_DFL);
if (ohandler != SDL_HandleSIG)
signal(SIGTERM, ohandler);
#endif /* HAVE_SIGNAL_H */
}
void SDL_SendPendingQuit ( void  )

Definition at line 144 of file SDL_quit.c.

References SDL_assert, SDL_SendQuit(), and send_quit_pending.

Referenced by SDL_PumpEvents().

int SDL_SendQuit ( void  )

Variable Documentation

SDL_bool disable_signals = SDL_FALSE
static

Definition at line 34 of file SDL_quit.c.

Referenced by SDL_QuitQuit().

SDL_bool send_quit_pending = SDL_FALSE
static

Definition at line 35 of file SDL_quit.c.

Referenced by SDL_HandleSIG(), SDL_SendPendingQuit(), and SDL_SendQuit().