6 * Calling signal() is non-portable, as it varies in meaning
\r
7 * between platforms and depending on feature macros, and has
\r
8 * stupid semantics at least some of the time.
\r
10 * This function provides the same interface as the libc function,
\r
11 * but provides consistent semantics. It assumes POSIX semantics
\r
12 * for sigaction() (so you might need to do some more work if you
\r
13 * port to something ancient like SunOS 4)
\r
15 void (*putty_signal(int sig, void (*func)(int)))(int) {
\r
16 struct sigaction sa;
\r
17 struct sigaction old;
\r
19 sa.sa_handler = func;
\r
20 if(sigemptyset(&sa.sa_mask) < 0)
\r
22 sa.sa_flags = SA_RESTART;
\r
23 if(sigaction(sig, &sa, &old) < 0)
\r
25 return old.sa_handler;
\r
28 void block_signal(int sig, int block_it)
\r
33 sigaddset(&ss, sig);
\r
34 if(sigprocmask(block_it ? SIG_BLOCK : SIG_UNBLOCK, &ss, 0) < 0) {
\r
35 perror("sigprocmask");
\r