annotate src/SDL_fatal.c @ 821:30168104389f

Date: Sat, 14 Feb 2004 14:52:40 +0200 From: "Mike Gorchak" Subject: Batch of the QNX6 fixes for the SDL 1. Updated readme.QNX 2. Fixed crashes during intensive window updating under fast machines (got over 200 rectangles for update). 3. Fixed double-buffered fullscreen modes, now it works as needed. 4. Fixed Photon detection algorithm. 5. Fixed HWSURFACE update function. 6. Added SDL_PHOTON_FULLSCREEN_REFRESH environment variable support for control refresh rates under Photon. 7. Added 640x400 fullscreen mode emulation via 640x480 (if videodriver not supports original 640x400 mode of course) shifted by 40 vertical pixels from begin, to center it. It's needed for some old DOS games which ran in doubled 320x200 mode. 8. Added available video ram amount support. 8. Added hardware surface allocation/deallocation support if current videomode and videodriver supports it. 9. Added hardware filling support. 10. Added hardware blits support (simple and colorkeyed). And I've added to testvidinfo test color-keyed blits benchmark (maybe need to add alpha blits benchmark too ?). Currently Photon not supporting any alpha hardware blittings (all drivers lack of alpha blitting code support, only software alpha blitting exist in photon, which is hundreds times slowest than the SDL's one). So I've not added the alpha support. I suppose new QNX 6.3 will have the hardware alpha support, so when it will be done, I'll add alpha support.
author Sam Lantinga <slouken@libsdl.org>
date Sat, 14 Feb 2004 20:22:21 +0000
parents 5a417d2a8603
children abb915adb1b0
rev   line source
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1 /*
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2 SDL - Simple DirectMedia Layer
769
b8d311d90021 Updated copyright information for 2004 (Happy New Year!)
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
3 Copyright (C) 1997-2004 Sam Lantinga
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
4
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
5 This library is free software; you can redistribute it and/or
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
6 modify it under the terms of the GNU Library General Public
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
7 License as published by the Free Software Foundation; either
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
8 version 2 of the License, or (at your option) any later version.
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
9
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
13 Library General Public License for more details.
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
14
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
15 You should have received a copy of the GNU Library General Public
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
16 License along with this library; if not, write to the Free
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
18
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
19 Sam Lantinga
252
e8157fcb3114 Updated the source with the correct e-mail address
Sam Lantinga <slouken@libsdl.org>
parents: 1
diff changeset
20 slouken@libsdl.org
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
21 */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
22
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
23 #ifdef SAVE_RCSID
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
24 static char rcsid =
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
25 "@(#) $Id$";
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
26 #endif
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
27
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
28 /* General fatal signal handling code for SDL */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
29
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
30 #ifdef NO_SIGNAL_H
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
31
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
32 /* No signals on this platform, nothing to do.. */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
33
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
34 void SDL_InstallParachute(void)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
35 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
36 return;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
37 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
38
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
39 void SDL_UninstallParachute(void)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
40 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
41 return;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
42 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
43
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
44 #else
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
45
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
46 #include <stdlib.h>
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
47 #include <stdio.h>
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
48 #include <signal.h>
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
49 #include <string.h>
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
50
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
51 #include "SDL.h"
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
52 #include "SDL_fatal.h"
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
53
1
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
54 #ifdef __CYGWIN__
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
55 #define DISABLE_STDIO
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
56 #endif
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
57
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
58 /* This installs some signal handlers for the more common fatal signals,
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
59 so that if the programmer is lazy, the app doesn't die so horribly if
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
60 the program crashes.
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
61 */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
62
1
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
63 static void print_msg(const char *text)
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
64 {
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
65 #ifndef DISABLE_STDIO
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
66 fprintf(stderr, "%s", text);
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
67 #endif
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
68 }
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
69
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
70 static void SDL_Parachute(int sig)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
71 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
72 signal(sig, SIG_DFL);
1
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
73 print_msg("Fatal signal: ");
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
74 switch (sig) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
75 case SIGSEGV:
1
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
76 print_msg("Segmentation Fault");
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
77 break;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
78 #ifdef SIGBUS
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
79 #if SIGBUS != SIGSEGV
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
80 case SIGBUS:
1
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
81 print_msg("Bus Error");
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
82 break;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
83 #endif
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
84 #endif /* SIGBUS */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
85 #ifdef SIGFPE
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
86 case SIGFPE:
1
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
87 print_msg("Floating Point Exception");
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
88 break;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
89 #endif /* SIGFPE */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
90 #ifdef SIGQUIT
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
91 case SIGQUIT:
1
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
92 print_msg("Keyboard Quit");
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
93 break;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
94 #endif /* SIGQUIT */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
95 #ifdef SIGPIPE
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
96 case SIGPIPE:
1
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
97 print_msg("Broken Pipe");
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
98 break;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
99 #endif /* SIGPIPE */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
100 default:
1
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
101 #ifndef DISABLE_STDIO
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
102 fprintf(stderr, "# %d", sig);
1
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
103 #endif
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
104 break;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
105 }
1
cf2af46e9e2a Changes since SDL 1.2.0 release
Sam Lantinga <slouken@lokigames.com>
parents: 0
diff changeset
106 print_msg(" (SDL Parachute Deployed)\n");
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
107 SDL_Quit();
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
108 exit(-sig);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
109 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
110
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
111 static int SDL_fatal_signals[] = {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
112 SIGSEGV,
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
113 #ifdef SIGBUS
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
114 SIGBUS,
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
115 #endif
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
116 #ifdef SIGFPE
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
117 SIGFPE,
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
118 #endif
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
119 #ifdef SIGQUIT
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
120 SIGQUIT,
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
121 #endif
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
122 #ifdef SIGPIPE
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
123 SIGPIPE,
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
124 #endif
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
125 0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
126 };
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
127
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
128 void SDL_InstallParachute(void)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
129 {
814
5a417d2a8603 Use sigaction instead of signal to preserve handler flags (thanks Matthew!)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
130 /* Set a handler for any fatal signal not already handled */
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
131 int i;
814
5a417d2a8603 Use sigaction instead of signal to preserve handler flags (thanks Matthew!)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
132 #ifdef HAVE_SIGACTION
5a417d2a8603 Use sigaction instead of signal to preserve handler flags (thanks Matthew!)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
133 struct sigaction action;
5a417d2a8603 Use sigaction instead of signal to preserve handler flags (thanks Matthew!)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
134
5a417d2a8603 Use sigaction instead of signal to preserve handler flags (thanks Matthew!)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
135 for ( i=0; SDL_fatal_signals[i]; ++i ) {
5a417d2a8603 Use sigaction instead of signal to preserve handler flags (thanks Matthew!)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
136 sigaction(SDL_fatal_signals[i], NULL, &action);
5a417d2a8603 Use sigaction instead of signal to preserve handler flags (thanks Matthew!)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
137 if ( action.sa_handler == SIG_DFL ) {
5a417d2a8603 Use sigaction instead of signal to preserve handler flags (thanks Matthew!)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
138 action.sa_handler = SDL_Parachute;
5a417d2a8603 Use sigaction instead of signal to preserve handler flags (thanks Matthew!)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
139 sigaction(SDL_fatal_signals[i], &action, NULL);
5a417d2a8603 Use sigaction instead of signal to preserve handler flags (thanks Matthew!)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
140 }
5a417d2a8603 Use sigaction instead of signal to preserve handler flags (thanks Matthew!)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
141 }
5a417d2a8603 Use sigaction instead of signal to preserve handler flags (thanks Matthew!)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
142 #ifdef SIGALRM
5a417d2a8603 Use sigaction instead of signal to preserve handler flags (thanks Matthew!)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
143 /* Set SIGALRM to be ignored -- necessary on Solaris */
5a417d2a8603 Use sigaction instead of signal to preserve handler flags (thanks Matthew!)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
144 sigaction(SIGALRM, NULL, &action);
5a417d2a8603 Use sigaction instead of signal to preserve handler flags (thanks Matthew!)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
145 if ( action.sa_handler == SIG_DFL ) {
5a417d2a8603 Use sigaction instead of signal to preserve handler flags (thanks Matthew!)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
146 action.sa_handler = SIG_IGN;
5a417d2a8603 Use sigaction instead of signal to preserve handler flags (thanks Matthew!)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
147 sigaction(SDL_fatal_signals[i], &action, NULL);
5a417d2a8603 Use sigaction instead of signal to preserve handler flags (thanks Matthew!)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
148 }
5a417d2a8603 Use sigaction instead of signal to preserve handler flags (thanks Matthew!)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
149 #endif
5a417d2a8603 Use sigaction instead of signal to preserve handler flags (thanks Matthew!)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
150 #else
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
151 void (*ohandler)(int);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
152
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
153 for ( i=0; SDL_fatal_signals[i]; ++i ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
154 ohandler = signal(SDL_fatal_signals[i], SDL_Parachute);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
155 if ( ohandler != SIG_DFL ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
156 signal(SDL_fatal_signals[i], ohandler);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
157 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
158 }
814
5a417d2a8603 Use sigaction instead of signal to preserve handler flags (thanks Matthew!)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
159 #endif /* HAVE_SIGACTION */
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
160 return;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
161 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
162
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
163 void SDL_UninstallParachute(void)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
164 {
814
5a417d2a8603 Use sigaction instead of signal to preserve handler flags (thanks Matthew!)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
165 /* Remove a handler for any fatal signal handled */
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
166 int i;
814
5a417d2a8603 Use sigaction instead of signal to preserve handler flags (thanks Matthew!)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
167 #ifdef HAVE_SIGACTION
5a417d2a8603 Use sigaction instead of signal to preserve handler flags (thanks Matthew!)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
168 struct sigaction action;
5a417d2a8603 Use sigaction instead of signal to preserve handler flags (thanks Matthew!)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
169
5a417d2a8603 Use sigaction instead of signal to preserve handler flags (thanks Matthew!)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
170 for ( i=0; SDL_fatal_signals[i]; ++i ) {
5a417d2a8603 Use sigaction instead of signal to preserve handler flags (thanks Matthew!)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
171 sigaction(SDL_fatal_signals[i], NULL, &action);
5a417d2a8603 Use sigaction instead of signal to preserve handler flags (thanks Matthew!)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
172 if ( action.sa_handler == SDL_Parachute ) {
5a417d2a8603 Use sigaction instead of signal to preserve handler flags (thanks Matthew!)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
173 action.sa_handler = SIG_DFL;
5a417d2a8603 Use sigaction instead of signal to preserve handler flags (thanks Matthew!)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
174 sigaction(SDL_fatal_signals[i], &action, NULL);
5a417d2a8603 Use sigaction instead of signal to preserve handler flags (thanks Matthew!)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
175 }
5a417d2a8603 Use sigaction instead of signal to preserve handler flags (thanks Matthew!)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
176 }
5a417d2a8603 Use sigaction instead of signal to preserve handler flags (thanks Matthew!)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
177 #else
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
178 void (*ohandler)(int);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
179
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
180 for ( i=0; SDL_fatal_signals[i]; ++i ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
181 ohandler = signal(SDL_fatal_signals[i], SIG_DFL);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
182 if ( ohandler != SDL_Parachute ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
183 signal(SDL_fatal_signals[i], ohandler);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
184 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
185 }
814
5a417d2a8603 Use sigaction instead of signal to preserve handler flags (thanks Matthew!)
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
186 #endif /* HAVE_SIGACTION */
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
187 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
188
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
189 #endif /* NO_SIGNAL_H */