3 * signals.c -- general signals interface for nmh
13 SIGPROCMASK (int how, const sigset_t *set, sigset_t *oset)
16 return sigprocmask(how, set, oset);
21 *oset = sigblock(*set);
25 *oset = sigsetmask(*oset);
26 sigsetmask(*oset & ~(*set));
29 *oset = sigsetmask(*set);
32 adios(NULL, "unknown flag in SIGPROCMASK");
42 * A version of the function `signal' that uses reliable
43 * signals, if the machine supports them. Also, (assuming
44 * OS support), it restarts interrupted system calls for all
45 * signals except SIGALRM.
49 SIGNAL (int sig, SIGNAL_HANDLER func)
52 struct sigaction act, oact;
54 act.sa_handler = func;
55 sigemptyset(&act.sa_mask);
60 act.sa_flags |= SA_INTERRUPT; /* SunOS */
64 act.sa_flags |= SA_RESTART; /* SVR4, BSD4.4 */
67 if (sigaction(sig, &act, &oact) < 0)
69 return (oact.sa_handler);
71 return signal (sig, func);
77 * A version of the function `signal' that will set
78 * the handler of `sig' to `func' if the signal is
79 * not currently set to SIG_IGN. Also uses reliable
80 * signals if available.
83 SIGNAL2 (int sig, SIGNAL_HANDLER func)
86 struct sigaction act, oact;
88 if (sigaction(sig, NULL, &oact) < 0)
90 if (oact.sa_handler != SIG_IGN) {
91 act.sa_handler = func;
92 sigemptyset(&act.sa_mask);
97 act.sa_flags |= SA_INTERRUPT; /* SunOS */
101 act.sa_flags |= SA_RESTART; /* SVR4, BSD4.4 */
104 if (sigaction(sig, &act, &oact) < 0)
107 return (oact.sa_handler);
109 SIGNAL_HANDLER ofunc;
111 if ((ofunc = signal (sig, SIG_IGN)) != SIG_IGN)