gbasys

diff src/signal.c @ 2:e3dc7705ad9c

communications stuff
author John Tsiombikas <nuclear@member.fsf.org>
date Wed, 07 Mar 2012 06:11:51 +0200
parents 875ef6085efc
children 06726f0b8cd3
line diff
     1.1 --- a/src/signal.c	Sun Mar 04 07:06:41 2012 +0200
     1.2 +++ b/src/signal.c	Wed Mar 07 06:11:51 2012 +0200
     1.3 @@ -32,11 +32,11 @@
     1.4  
     1.5  void sig_init(void) {
     1.6  	int i;
     1.7 -	
     1.8 +
     1.9  	for(i=0; i<SIG_MAX; i++) {
    1.10  		default_sig_handler[i] = sig_invalid_handler;
    1.11  	}
    1.12 -	
    1.13 +
    1.14  	default_sig_handler[SIGALRM] = SIG_IGN;
    1.15  	default_sig_handler[SIGUSR1] = SIG_IGN;
    1.16  	default_sig_handler[SIGUSR2] = SIG_IGN;
    1.17 @@ -48,9 +48,9 @@
    1.18  
    1.19  sighandler_t signal(int signum, sighandler_t handler) {
    1.20  	sighandler_t prev = signal_handler[signum];
    1.21 -	
    1.22 +
    1.23  	signal_handler[signum] = handler == SIG_IGN ? 0 : (handler == SIG_DFL ? default_sig_handler[signum] : handler);
    1.24 -	
    1.25 +
    1.26  	return prev;
    1.27  }
    1.28  
    1.29 @@ -68,7 +68,7 @@
    1.30  	set_int();
    1.31  
    1.32  	while(wait_for_signal);
    1.33 -	
    1.34 +
    1.35  	/*errno = EINTR;*/
    1.36  	return -1;
    1.37  }
    1.38 @@ -80,3 +80,8 @@
    1.39  void restore_signal(int signum) {
    1.40  	signal_handler[signum] = saved_signal;
    1.41  }
    1.42 +
    1.43 +sighandler_t signal_func(int signum)
    1.44 +{
    1.45 +	return signal_handler[signum];
    1.46 +}