2 * tc.sig.c: Signal routine emulations
5 * Copyright (c) 1980, 1991 The Regents of the University of California.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. Neither the name of the University nor the names of its contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 sigset_interrupting(int sig
, void (*fn
) (int))
41 sigemptyset(&act
.sa_mask
);
43 if (sigaction(sig
, &act
, NULL
) == 0) {
47 sigprocmask(SIG_UNBLOCK
, &set
, NULL
);
51 static volatile sig_atomic_t alrmcatch_pending
; /* = 0; */
52 static volatile sig_atomic_t pchild_pending
; /* = 0; */
53 static volatile sig_atomic_t phup_pending
; /* = 0; */
54 static volatile sig_atomic_t pintr_pending
; /* = 0; */
55 int alrmcatch_disabled
; /* = 0; */
56 int phup_disabled
; /* = 0; */
57 int pchild_disabled
; /* = 0; */
58 int pintr_disabled
; /* = 0; */
61 handle_pending_signals(void)
64 if (!phup_disabled
&& phup_pending
) {
70 if (!pintr_disabled
&& pintr_pending
) {
77 if (!pchild_disabled
&& pchild_pending
) {
83 if (!alrmcatch_disabled
&& alrmcatch_pending
) {
84 alrmcatch_pending
= 0;
93 queue_alrmcatch(int sig
)
96 alrmcatch_pending
= 1;
100 queue_pchild(int sig
)
121 disabled_cleanup(void *xdisabled
)
125 disabled
= xdisabled
;
126 if (--*disabled
== 0)
127 handle_pending_signals();
131 pintr_disabled_restore(void *xold
)
136 pintr_disabled
= *old
;
140 pintr_push_enable(int *saved
)
142 *saved
= pintr_disabled
;
144 cleanup_push(saved
, pintr_disabled_restore
);
145 handle_pending_signals();