src/SDL_fatal.c
changeset 1895 c121d94672cb
parent 1402 d910939febfa
child 2859 99210400e8b9
     1.1 --- a/src/SDL_fatal.c	Thu Jul 06 18:01:37 2006 +0000
     1.2 +++ b/src/SDL_fatal.c	Mon Jul 10 21:04:37 2006 +0000
     1.3 @@ -35,85 +35,88 @@
     1.4     the program crashes.
     1.5  */
     1.6  
     1.7 -static void SDL_Parachute(int sig)
     1.8 +static void
     1.9 +SDL_Parachute(int sig)
    1.10  {
    1.11 -	signal(sig, SIG_DFL);
    1.12 -	SDL_Quit();
    1.13 -	raise(sig);
    1.14 +    signal(sig, SIG_DFL);
    1.15 +    SDL_Quit();
    1.16 +    raise(sig);
    1.17  }
    1.18  
    1.19  static int SDL_fatal_signals[] = {
    1.20 -	SIGSEGV,
    1.21 +    SIGSEGV,
    1.22  #ifdef SIGBUS
    1.23 -	SIGBUS,
    1.24 +    SIGBUS,
    1.25  #endif
    1.26  #ifdef SIGFPE
    1.27 -	SIGFPE,
    1.28 +    SIGFPE,
    1.29  #endif
    1.30  #ifdef SIGQUIT
    1.31 -	SIGQUIT,
    1.32 +    SIGQUIT,
    1.33  #endif
    1.34 -	0
    1.35 +    0
    1.36  };
    1.37  
    1.38 -void SDL_InstallParachute(void)
    1.39 +void
    1.40 +SDL_InstallParachute(void)
    1.41  {
    1.42 -	/* Set a handler for any fatal signal not already handled */
    1.43 -	int i;
    1.44 +    /* Set a handler for any fatal signal not already handled */
    1.45 +    int i;
    1.46  #ifdef HAVE_SIGACTION
    1.47 -	struct sigaction action;
    1.48 +    struct sigaction action;
    1.49  
    1.50 -	for ( i=0; SDL_fatal_signals[i]; ++i ) {
    1.51 -		sigaction(SDL_fatal_signals[i], NULL, &action);
    1.52 -		if ( action.sa_handler == SIG_DFL ) {
    1.53 -			action.sa_handler = SDL_Parachute;
    1.54 -			sigaction(SDL_fatal_signals[i], &action, NULL);
    1.55 -		}
    1.56 -	}
    1.57 +    for (i = 0; SDL_fatal_signals[i]; ++i) {
    1.58 +        sigaction(SDL_fatal_signals[i], NULL, &action);
    1.59 +        if (action.sa_handler == SIG_DFL) {
    1.60 +            action.sa_handler = SDL_Parachute;
    1.61 +            sigaction(SDL_fatal_signals[i], &action, NULL);
    1.62 +        }
    1.63 +    }
    1.64  #ifdef SIGALRM
    1.65 -	/* Set SIGALRM to be ignored -- necessary on Solaris */
    1.66 -	sigaction(SIGALRM, NULL, &action);
    1.67 -	if ( action.sa_handler == SIG_DFL ) {
    1.68 -		action.sa_handler = SIG_IGN;
    1.69 -		sigaction(SIGALRM, &action, NULL);
    1.70 -	}
    1.71 +    /* Set SIGALRM to be ignored -- necessary on Solaris */
    1.72 +    sigaction(SIGALRM, NULL, &action);
    1.73 +    if (action.sa_handler == SIG_DFL) {
    1.74 +        action.sa_handler = SIG_IGN;
    1.75 +        sigaction(SIGALRM, &action, NULL);
    1.76 +    }
    1.77  #endif
    1.78  #else
    1.79 -	void (*ohandler)(int);
    1.80 +    void (*ohandler) (int);
    1.81  
    1.82 -	for ( i=0; SDL_fatal_signals[i]; ++i ) {
    1.83 -		ohandler = signal(SDL_fatal_signals[i], SDL_Parachute);
    1.84 -		if ( ohandler != SIG_DFL ) {
    1.85 -			signal(SDL_fatal_signals[i], ohandler);
    1.86 -		}
    1.87 -	}
    1.88 +    for (i = 0; SDL_fatal_signals[i]; ++i) {
    1.89 +        ohandler = signal(SDL_fatal_signals[i], SDL_Parachute);
    1.90 +        if (ohandler != SIG_DFL) {
    1.91 +            signal(SDL_fatal_signals[i], ohandler);
    1.92 +        }
    1.93 +    }
    1.94  #endif /* HAVE_SIGACTION */
    1.95 -	return;
    1.96 +    return;
    1.97  }
    1.98  
    1.99 -void SDL_UninstallParachute(void)
   1.100 +void
   1.101 +SDL_UninstallParachute(void)
   1.102  {
   1.103 -	/* Remove a handler for any fatal signal handled */
   1.104 -	int i;
   1.105 +    /* Remove a handler for any fatal signal handled */
   1.106 +    int i;
   1.107  #ifdef HAVE_SIGACTION
   1.108 -	struct sigaction action;
   1.109 +    struct sigaction action;
   1.110  
   1.111 -	for ( i=0; SDL_fatal_signals[i]; ++i ) {
   1.112 -		sigaction(SDL_fatal_signals[i], NULL, &action);
   1.113 -		if ( action.sa_handler == SDL_Parachute ) {
   1.114 -			action.sa_handler = SIG_DFL;
   1.115 -			sigaction(SDL_fatal_signals[i], &action, NULL);
   1.116 -		}
   1.117 -	}
   1.118 +    for (i = 0; SDL_fatal_signals[i]; ++i) {
   1.119 +        sigaction(SDL_fatal_signals[i], NULL, &action);
   1.120 +        if (action.sa_handler == SDL_Parachute) {
   1.121 +            action.sa_handler = SIG_DFL;
   1.122 +            sigaction(SDL_fatal_signals[i], &action, NULL);
   1.123 +        }
   1.124 +    }
   1.125  #else
   1.126 -	void (*ohandler)(int);
   1.127 +    void (*ohandler) (int);
   1.128  
   1.129 -	for ( i=0; SDL_fatal_signals[i]; ++i ) {
   1.130 -		ohandler = signal(SDL_fatal_signals[i], SIG_DFL);
   1.131 -		if ( ohandler != SDL_Parachute ) {
   1.132 -			signal(SDL_fatal_signals[i], ohandler);
   1.133 -		}
   1.134 -	}
   1.135 +    for (i = 0; SDL_fatal_signals[i]; ++i) {
   1.136 +        ohandler = signal(SDL_fatal_signals[i], SIG_DFL);
   1.137 +        if (ohandler != SDL_Parachute) {
   1.138 +            signal(SDL_fatal_signals[i], ohandler);
   1.139 +        }
   1.140 +    }
   1.141  #endif /* HAVE_SIGACTION */
   1.142  }
   1.143  
   1.144 @@ -121,14 +124,17 @@
   1.145  
   1.146  /* No signals on this platform, nothing to do.. */
   1.147  
   1.148 -void SDL_InstallParachute(void)
   1.149 +void
   1.150 +SDL_InstallParachute(void)
   1.151  {
   1.152 -	return;
   1.153 +    return;
   1.154  }
   1.155  
   1.156 -void SDL_UninstallParachute(void)
   1.157 +void
   1.158 +SDL_UninstallParachute(void)
   1.159  {
   1.160 -	return;
   1.161 +    return;
   1.162  }
   1.163  
   1.164  #endif /* HAVE_SIGNAL_H */
   1.165 +/* vi: set ts=4 sw=4 expandtab: */