Mercurial > sdl-ios-xcode
comparison src/events/SDL_quit.c @ 1123:28ac87a38c17
Date: Fri, 08 Jul 2005 22:43:48 +0200 (CEST)
From: Jiri Svoboda
Subject: [SDL] signal handling bug
I encountered the following bug:
SDL doesn't reset signal handlers for SIGTERM and SIGINT, after calling SDL_Quit these remain hooked to the handler in SDL_quit.c, being translated into SDL_QUIT events.
Consequently an application that issues a SDL_Quit and remains running will ignore any SIGTERM or SIGINT., and specifically CTRL-C presses.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sun, 21 Aug 2005 06:18:54 +0000 |
parents | b8d311d90021 |
children | 51a8702d8ecd |
comparison
equal
deleted
inserted
replaced
1122:e253d5448fce | 1123:28ac87a38c17 |
---|---|
52 { | 52 { |
53 #ifndef NO_SIGNAL_H | 53 #ifndef NO_SIGNAL_H |
54 void (*ohandler)(int); | 54 void (*ohandler)(int); |
55 | 55 |
56 /* Both SIGINT and SIGTERM are translated into quit interrupts */ | 56 /* Both SIGINT and SIGTERM are translated into quit interrupts */ |
57 ohandler = signal(SIGINT, SDL_HandleSIG); | 57 ohandler = signal(SIGINT, SDL_HandleSIG); |
58 if ( ohandler != SIG_DFL ) | 58 if ( ohandler != SIG_DFL ) |
59 signal(SIGINT, ohandler); | 59 signal(SIGINT, ohandler); |
60 ohandler = signal(SIGTERM, SDL_HandleSIG); | 60 ohandler = signal(SIGTERM, SDL_HandleSIG); |
61 if ( ohandler != SIG_DFL ) | 61 if ( ohandler != SIG_DFL ) |
62 signal(SIGTERM, ohandler); | 62 signal(SIGTERM, ohandler); |
63 #endif /* NO_SIGNAL_H */ | 63 #endif /* NO_SIGNAL_H */ |
64 | 64 |
65 /* That's it! */ | 65 /* That's it! */ |
66 return(0); | 66 return(0); |
67 } | |
68 void SDL_QuitQuit(void) | |
69 { | |
70 #ifndef NO_SIGNAL_H | |
71 void (*ohandler)(int); | |
72 | |
73 ohandler = signal(SIGINT, SIG_DFL); | |
74 if ( ohandler != SDL_HandleSIG ) | |
75 signal(SIGINT, ohandler); | |
76 ohandler = signal(SIGTERM, SIG_DFL); | |
77 if ( ohandler != SDL_HandleSIG ) | |
78 signal(SIGTERM, ohandler); | |
79 #endif /* NO_SIGNAL_H */ | |
67 } | 80 } |
68 | 81 |
69 /* This function returns 1 if it's okay to close the application window */ | 82 /* This function returns 1 if it's okay to close the application window */ |
70 int SDL_PrivateQuit(void) | 83 int SDL_PrivateQuit(void) |
71 { | 84 { |