comparison src/SDL_fatal.c @ 1668:4da1ee79c9af SDL-1.3

more tweaking indent options
author Sam Lantinga <slouken@libsdl.org>
date Mon, 29 May 2006 04:04:35 +0000
parents 782fd950bd46
children
comparison
equal deleted inserted replaced
1667:1fddae038bc8 1668:4da1ee79c9af
34 so that if the programmer is lazy, the app doesn't die so horribly if 34 so that if the programmer is lazy, the app doesn't die so horribly if
35 the program crashes. 35 the program crashes.
36 */ 36 */
37 37
38 static void 38 static void
39 SDL_Parachute (int sig) 39 SDL_Parachute(int sig)
40 { 40 {
41 signal (sig, SIG_DFL); 41 signal(sig, SIG_DFL);
42 SDL_Quit (); 42 SDL_Quit();
43 raise (sig); 43 raise(sig);
44 } 44 }
45 45
46 static int SDL_fatal_signals[] = { 46 static int SDL_fatal_signals[] = {
47 SIGSEGV, 47 SIGSEGV,
48 #ifdef SIGBUS 48 #ifdef SIGBUS
56 #endif 56 #endif
57 0 57 0
58 }; 58 };
59 59
60 void 60 void
61 SDL_InstallParachute (void) 61 SDL_InstallParachute(void)
62 { 62 {
63 /* Set a handler for any fatal signal not already handled */ 63 /* Set a handler for any fatal signal not already handled */
64 int i; 64 int i;
65 #ifdef HAVE_SIGACTION 65 #ifdef HAVE_SIGACTION
66 struct sigaction action; 66 struct sigaction action;
67 67
68 for (i = 0; SDL_fatal_signals[i]; ++i) { 68 for (i = 0; SDL_fatal_signals[i]; ++i) {
69 sigaction (SDL_fatal_signals[i], NULL, &action); 69 sigaction(SDL_fatal_signals[i], NULL, &action);
70 if (action.sa_handler == SIG_DFL) { 70 if (action.sa_handler == SIG_DFL) {
71 action.sa_handler = SDL_Parachute; 71 action.sa_handler = SDL_Parachute;
72 sigaction (SDL_fatal_signals[i], &action, NULL); 72 sigaction(SDL_fatal_signals[i], &action, NULL);
73 } 73 }
74 } 74 }
75 #ifdef SIGALRM 75 #ifdef SIGALRM
76 /* Set SIGALRM to be ignored -- necessary on Solaris */ 76 /* Set SIGALRM to be ignored -- necessary on Solaris */
77 sigaction (SIGALRM, NULL, &action); 77 sigaction(SIGALRM, NULL, &action);
78 if (action.sa_handler == SIG_DFL) { 78 if (action.sa_handler == SIG_DFL) {
79 action.sa_handler = SIG_IGN; 79 action.sa_handler = SIG_IGN;
80 sigaction (SIGALRM, &action, NULL); 80 sigaction(SIGALRM, &action, NULL);
81 } 81 }
82 #endif 82 #endif
83 #else 83 #else
84 void (*ohandler) (int); 84 void (*ohandler) (int);
85 85
86 for (i = 0; SDL_fatal_signals[i]; ++i) { 86 for (i = 0; SDL_fatal_signals[i]; ++i) {
87 ohandler = signal (SDL_fatal_signals[i], SDL_Parachute); 87 ohandler = signal(SDL_fatal_signals[i], SDL_Parachute);
88 if (ohandler != SIG_DFL) { 88 if (ohandler != SIG_DFL) {
89 signal (SDL_fatal_signals[i], ohandler); 89 signal(SDL_fatal_signals[i], ohandler);
90 } 90 }
91 } 91 }
92 #endif /* HAVE_SIGACTION */ 92 #endif /* HAVE_SIGACTION */
93 return; 93 return;
94 } 94 }
95 95
96 void 96 void
97 SDL_UninstallParachute (void) 97 SDL_UninstallParachute(void)
98 { 98 {
99 /* Remove a handler for any fatal signal handled */ 99 /* Remove a handler for any fatal signal handled */
100 int i; 100 int i;
101 #ifdef HAVE_SIGACTION 101 #ifdef HAVE_SIGACTION
102 struct sigaction action; 102 struct sigaction action;
103 103
104 for (i = 0; SDL_fatal_signals[i]; ++i) { 104 for (i = 0; SDL_fatal_signals[i]; ++i) {
105 sigaction (SDL_fatal_signals[i], NULL, &action); 105 sigaction(SDL_fatal_signals[i], NULL, &action);
106 if (action.sa_handler == SDL_Parachute) { 106 if (action.sa_handler == SDL_Parachute) {
107 action.sa_handler = SIG_DFL; 107 action.sa_handler = SIG_DFL;
108 sigaction (SDL_fatal_signals[i], &action, NULL); 108 sigaction(SDL_fatal_signals[i], &action, NULL);
109 } 109 }
110 } 110 }
111 #else 111 #else
112 void (*ohandler) (int); 112 void (*ohandler) (int);
113 113
114 for (i = 0; SDL_fatal_signals[i]; ++i) { 114 for (i = 0; SDL_fatal_signals[i]; ++i) {
115 ohandler = signal (SDL_fatal_signals[i], SIG_DFL); 115 ohandler = signal(SDL_fatal_signals[i], SIG_DFL);
116 if (ohandler != SDL_Parachute) { 116 if (ohandler != SDL_Parachute) {
117 signal (SDL_fatal_signals[i], ohandler); 117 signal(SDL_fatal_signals[i], ohandler);
118 } 118 }
119 } 119 }
120 #endif /* HAVE_SIGACTION */ 120 #endif /* HAVE_SIGACTION */
121 } 121 }
122 122
123 #else 123 #else
124 124
125 /* No signals on this platform, nothing to do.. */ 125 /* No signals on this platform, nothing to do.. */
126 126
127 void 127 void
128 SDL_InstallParachute (void) 128 SDL_InstallParachute(void)
129 { 129 {
130 return; 130 return;
131 } 131 }
132 132
133 void 133 void
134 SDL_UninstallParachute (void) 134 SDL_UninstallParachute(void)
135 { 135 {
136 return; 136 return;
137 } 137 }
138 138
139 #endif /* HAVE_SIGNAL_H */ 139 #endif /* HAVE_SIGNAL_H */