]> asedeno.scripts.mit.edu Git - PuTTY.git/blob - unix/signal.c
Move MODULE files out of individual project directories into a
[PuTTY.git] / unix / signal.c
1 #include <signal.h>
2
3 /*
4  * Calling signal() is a non-portable, as it varies in meaning between
5  * platforms and depending on feature macros, and has stupid semantics
6  * at least some of the time.
7  *
8  * This function provides the same interface as the libc function, but
9  * provides consistent semantics.  It assumes POSIX semantics for
10  * sigaction() (so you might need to do some more work if you port to
11  * something ancient like SunOS 4)
12  */
13 void (*putty_signal(int sig, void (*func)(int)))(int) {
14     struct sigaction sa;
15     struct sigaction old;
16     
17     sa.sa_handler = func;
18     if(sigemptyset(&sa.sa_mask) < 0)
19         return SIG_ERR;
20     sa.sa_flags = SA_RESTART;
21     if(sigaction(sig, &sa, &old) < 0)
22         return SIG_ERR;
23     return old.sa_handler;
24 }
25
26 /*
27 Local Variables:
28 c-basic-offset:4
29 comment-column:40
30 End:
31 */