Mercurial > sdl-ios-xcode
comparison src/SDL_fatal.c @ 1:cf2af46e9e2a
Changes since SDL 1.2.0 release
author | Sam Lantinga <slouken@lokigames.com> |
---|---|
date | Thu, 26 Apr 2001 16:50:19 +0000 |
parents | 74212992fb08 |
children | e8157fcb3114 |
comparison
equal
deleted
inserted
replaced
0:74212992fb08 | 1:cf2af46e9e2a |
---|---|
49 #include <string.h> | 49 #include <string.h> |
50 | 50 |
51 #include "SDL.h" | 51 #include "SDL.h" |
52 #include "SDL_fatal.h" | 52 #include "SDL_fatal.h" |
53 | 53 |
54 #ifdef __CYGWIN__ | |
55 #define DISABLE_STDIO | |
56 #endif | |
57 | |
54 /* This installs some signal handlers for the more common fatal signals, | 58 /* This installs some signal handlers for the more common fatal signals, |
55 so that if the programmer is lazy, the app doesn't die so horribly if | 59 so that if the programmer is lazy, the app doesn't die so horribly if |
56 the program crashes. | 60 the program crashes. |
57 */ | 61 */ |
58 | 62 |
63 static void print_msg(const char *text) | |
64 { | |
65 #ifndef DISABLE_STDIO | |
66 fprintf(stderr, "%s", text); | |
67 #endif | |
68 } | |
69 | |
59 static void SDL_Parachute(int sig) | 70 static void SDL_Parachute(int sig) |
60 { | 71 { |
61 signal(sig, SIG_DFL); | 72 signal(sig, SIG_DFL); |
62 fprintf(stderr, "Fatal signal: "); | 73 print_msg("Fatal signal: "); |
63 switch (sig) { | 74 switch (sig) { |
64 case SIGSEGV: | 75 case SIGSEGV: |
65 fprintf(stderr, "Segmentation Fault"); | 76 print_msg("Segmentation Fault"); |
66 break; | 77 break; |
67 #ifdef SIGBUS | 78 #ifdef SIGBUS |
68 #if SIGBUS != SIGSEGV | 79 #if SIGBUS != SIGSEGV |
69 case SIGBUS: | 80 case SIGBUS: |
70 fprintf(stderr, "Bus Error"); | 81 print_msg("Bus Error"); |
71 break; | 82 break; |
72 #endif | 83 #endif |
73 #endif /* SIGBUS */ | 84 #endif /* SIGBUS */ |
74 #ifdef SIGFPE | 85 #ifdef SIGFPE |
75 case SIGFPE: | 86 case SIGFPE: |
76 fprintf(stderr, "Floating Point Exception"); | 87 print_msg("Floating Point Exception"); |
77 break; | 88 break; |
78 #endif /* SIGFPE */ | 89 #endif /* SIGFPE */ |
79 #ifdef SIGQUIT | 90 #ifdef SIGQUIT |
80 case SIGQUIT: | 91 case SIGQUIT: |
81 fprintf(stderr, "Keyboard Quit"); | 92 print_msg("Keyboard Quit"); |
82 break; | 93 break; |
83 #endif /* SIGQUIT */ | 94 #endif /* SIGQUIT */ |
84 #ifdef SIGPIPE | 95 #ifdef SIGPIPE |
85 case SIGPIPE: | 96 case SIGPIPE: |
86 fprintf(stderr, "Broken Pipe"); | 97 print_msg("Broken Pipe"); |
87 break; | 98 break; |
88 #endif /* SIGPIPE */ | 99 #endif /* SIGPIPE */ |
89 default: | 100 default: |
101 #ifndef DISABLE_STDIO | |
90 fprintf(stderr, "# %d", sig); | 102 fprintf(stderr, "# %d", sig); |
103 #endif | |
91 break; | 104 break; |
92 } | 105 } |
93 fprintf(stderr, " (SDL Parachute Deployed)\n"); | 106 print_msg(" (SDL Parachute Deployed)\n"); |
94 SDL_Quit(); | 107 SDL_Quit(); |
95 exit(-sig); | 108 exit(-sig); |
96 } | 109 } |
97 | 110 |
98 static int SDL_fatal_signals[] = { | 111 static int SDL_fatal_signals[] = { |