]>
diplodocus.org Git - nmh/blob - sbr/signals.c
3 * signals.c -- general signals interface for nmh
5 * This code is Copyright (c) 2002, by the authors of nmh. See the
6 * COPYRIGHT file in the root directory of the nmh distribution for
7 * complete copyright information.
11 #include <h/signals.h>
15 SIGPROCMASK (int how
, const sigset_t
*set
, sigset_t
*oset
)
18 return sigprocmask(how
, set
, oset
);
23 *oset
= sigblock(*set
);
27 *oset
= sigsetmask(*oset
);
28 sigsetmask(*oset
& ~(*set
));
31 *oset
= sigsetmask(*set
);
34 adios(NULL
, "unknown flag in SIGPROCMASK");
44 * A version of the function `signal' that uses reliable
45 * signals, if the machine supports them. Also, (assuming
46 * OS support), it restarts interrupted system calls for all
47 * signals except SIGALRM.
51 SIGNAL (int sig
, SIGNAL_HANDLER func
)
54 struct sigaction act
, oact
;
56 act
.sa_handler
= func
;
57 sigemptyset(&act
.sa_mask
);
62 act
.sa_flags
|= SA_INTERRUPT
; /* SunOS */
66 act
.sa_flags
|= SA_RESTART
; /* SVR4, BSD4.4 */
69 if (sigaction(sig
, &act
, &oact
) < 0)
71 return (oact
.sa_handler
);
73 return signal (sig
, func
);
79 * A version of the function `signal' that will set
80 * the handler of `sig' to `func' if the signal is
81 * not currently set to SIG_IGN. Also uses reliable
82 * signals if available.
85 SIGNAL2 (int sig
, SIGNAL_HANDLER func
)
88 struct sigaction act
, oact
;
90 if (sigaction(sig
, NULL
, &oact
) < 0)
92 if (oact
.sa_handler
!= SIG_IGN
) {
93 act
.sa_handler
= func
;
94 sigemptyset(&act
.sa_mask
);
99 act
.sa_flags
|= SA_INTERRUPT
; /* SunOS */
103 act
.sa_flags
|= SA_RESTART
; /* SVR4, BSD4.4 */
106 if (sigaction(sig
, &act
, &oact
) < 0)
109 return (oact
.sa_handler
);
111 SIGNAL_HANDLER ofunc
;
113 if ((ofunc
= signal (sig
, SIG_IGN
)) != SIG_IGN
)