src/SDL_fatal.c
changeset 1 cf2af46e9e2a
parent 0 74212992fb08
child 252 e8157fcb3114
     1.1 --- a/src/SDL_fatal.c	Thu Apr 26 16:45:43 2001 +0000
     1.2 +++ b/src/SDL_fatal.c	Thu Apr 26 16:50:19 2001 +0000
     1.3 @@ -51,46 +51,59 @@
     1.4  #include "SDL.h"
     1.5  #include "SDL_fatal.h"
     1.6  
     1.7 +#ifdef __CYGWIN__
     1.8 +#define DISABLE_STDIO
     1.9 +#endif
    1.10 +
    1.11  /* This installs some signal handlers for the more common fatal signals,
    1.12     so that if the programmer is lazy, the app doesn't die so horribly if
    1.13     the program crashes.
    1.14  */
    1.15  
    1.16 +static void print_msg(const char *text)
    1.17 +{
    1.18 +#ifndef DISABLE_STDIO
    1.19 +	fprintf(stderr, "%s", text);
    1.20 +#endif
    1.21 +}
    1.22 +
    1.23  static void SDL_Parachute(int sig)
    1.24  {
    1.25  	signal(sig, SIG_DFL);
    1.26 -	fprintf(stderr, "Fatal signal: ");
    1.27 +	print_msg("Fatal signal: ");
    1.28  	switch (sig) {
    1.29  		case SIGSEGV:
    1.30 -			fprintf(stderr, "Segmentation Fault");
    1.31 +			print_msg("Segmentation Fault");
    1.32  			break;
    1.33  #ifdef SIGBUS
    1.34  #if SIGBUS != SIGSEGV
    1.35  		case SIGBUS:
    1.36 -			fprintf(stderr, "Bus Error");
    1.37 +			print_msg("Bus Error");
    1.38  			break;
    1.39  #endif
    1.40  #endif /* SIGBUS */
    1.41  #ifdef SIGFPE
    1.42  		case SIGFPE:
    1.43 -			fprintf(stderr, "Floating Point Exception");
    1.44 +			print_msg("Floating Point Exception");
    1.45  			break;
    1.46  #endif /* SIGFPE */
    1.47  #ifdef SIGQUIT
    1.48  		case SIGQUIT:
    1.49 -			fprintf(stderr, "Keyboard Quit");
    1.50 +			print_msg("Keyboard Quit");
    1.51  			break;
    1.52  #endif /* SIGQUIT */
    1.53  #ifdef SIGPIPE
    1.54  		case SIGPIPE:
    1.55 -			fprintf(stderr, "Broken Pipe");
    1.56 +			print_msg("Broken Pipe");
    1.57  			break;
    1.58  #endif /* SIGPIPE */
    1.59  		default:
    1.60 +#ifndef DISABLE_STDIO
    1.61  			fprintf(stderr, "# %d", sig);
    1.62 +#endif
    1.63  			break;
    1.64  	}
    1.65 -	fprintf(stderr, " (SDL Parachute Deployed)\n");
    1.66 +	print_msg(" (SDL Parachute Deployed)\n");
    1.67  	SDL_Quit();
    1.68  	exit(-sig);
    1.69  }