src/SDL_fatal.c
changeset 1330 450721ad5436
parent 1312 c9b51268668f
child 1402 d910939febfa
     1.1 --- a/src/SDL_fatal.c	Sat Feb 04 22:01:44 2006 +0000
     1.2 +++ b/src/SDL_fatal.c	Mon Feb 06 08:28:51 2006 +0000
     1.3 @@ -20,91 +20,27 @@
     1.4      slouken@libsdl.org
     1.5  */
     1.6  
     1.7 -#ifdef _WIN32_WCE
     1.8 -#define NO_SIGNAL_H
     1.9 -#endif
    1.10 - 
    1.11  /* General fatal signal handling code for SDL */
    1.12  
    1.13 -#ifdef NO_SIGNAL_H
    1.14 -
    1.15 -/* No signals on this platform, nothing to do.. */
    1.16 -
    1.17 -void SDL_InstallParachute(void)
    1.18 -{
    1.19 -	return;
    1.20 -}
    1.21 +#include "SDL_config.h"
    1.22  
    1.23 -void SDL_UninstallParachute(void)
    1.24 -{
    1.25 -	return;
    1.26 -}
    1.27 +#ifdef HAVE_SIGNAL_H
    1.28  
    1.29 -#else
    1.30 -
    1.31 -#include <stdlib.h>
    1.32 -#include <stdio.h>
    1.33  #include <signal.h>
    1.34 -#include <string.h>
    1.35  
    1.36  #include "SDL.h"
    1.37  #include "SDL_fatal.h"
    1.38  
    1.39 -#ifdef __CYGWIN__
    1.40 -#define DISABLE_STDIO
    1.41 -#endif
    1.42 -
    1.43  /* This installs some signal handlers for the more common fatal signals,
    1.44     so that if the programmer is lazy, the app doesn't die so horribly if
    1.45     the program crashes.
    1.46  */
    1.47  
    1.48 -static void print_msg(const char *text)
    1.49 -{
    1.50 -#ifndef DISABLE_STDIO
    1.51 -	fprintf(stderr, "%s", text);
    1.52 -#endif
    1.53 -}
    1.54 -
    1.55  static void SDL_Parachute(int sig)
    1.56  {
    1.57  	signal(sig, SIG_DFL);
    1.58 -	print_msg("Fatal signal: ");
    1.59 -	switch (sig) {
    1.60 -		case SIGSEGV:
    1.61 -			print_msg("Segmentation Fault");
    1.62 -			break;
    1.63 -#ifdef SIGBUS
    1.64 -#if SIGBUS != SIGSEGV
    1.65 -		case SIGBUS:
    1.66 -			print_msg("Bus Error");
    1.67 -			break;
    1.68 -#endif
    1.69 -#endif /* SIGBUS */
    1.70 -#ifdef SIGFPE
    1.71 -		case SIGFPE:
    1.72 -			print_msg("Floating Point Exception");
    1.73 -			break;
    1.74 -#endif /* SIGFPE */
    1.75 -#ifdef SIGQUIT
    1.76 -		case SIGQUIT:
    1.77 -			print_msg("Keyboard Quit");
    1.78 -			break;
    1.79 -#endif /* SIGQUIT */
    1.80 -#ifdef SIGPIPE
    1.81 -		case SIGPIPE:
    1.82 -			print_msg("Broken Pipe");
    1.83 -			break;
    1.84 -#endif /* SIGPIPE */
    1.85 -		default:
    1.86 -#ifndef DISABLE_STDIO
    1.87 -			fprintf(stderr, "# %d", sig);
    1.88 -#endif
    1.89 -			break;
    1.90 -	}
    1.91 -	print_msg(" (SDL Parachute Deployed)\n");
    1.92  	SDL_Quit();
    1.93 -	exit(-sig);
    1.94 +	raise(sig);
    1.95  }
    1.96  
    1.97  static int SDL_fatal_signals[] = {
    1.98 @@ -182,4 +118,18 @@
    1.99  #endif /* HAVE_SIGACTION */
   1.100  }
   1.101  
   1.102 -#endif /* NO_SIGNAL_H */
   1.103 +#else
   1.104 +
   1.105 +/* No signals on this platform, nothing to do.. */
   1.106 +
   1.107 +void SDL_InstallParachute(void)
   1.108 +{
   1.109 +	return;
   1.110 +}
   1.111 +
   1.112 +void SDL_UninstallParachute(void)
   1.113 +{
   1.114 +	return;
   1.115 +}
   1.116 +
   1.117 +#endif /* HAVE_SIGNAL_H */