2 * SPDX-License-Identifier: BSD-3-Clause
4 * Copyright (c) 1989, 1993
5 * The Regents of the University of California. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the University nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 #if defined(LIBC_SCCS) && !defined(lint)
33 static char sccsid[] = "@(#)sigcompat.c 8.1 (Berkeley) 6/2/93";
34 #endif /* LIBC_SCCS and not lint */
35 #include "namespace.h"
36 #include <sys/param.h>
40 #include "un-namespace.h"
41 #include "libc_private.h"
44 sigvec(int signo, struct sigvec *sv, struct sigvec *osv)
46 struct sigaction sa, osa;
47 struct sigaction *sap, *osap;
51 sa.sa_handler = sv->sv_handler;
52 sa.sa_flags = sv->sv_flags ^ SV_INTERRUPT;
53 sigemptyset(&sa.sa_mask);
54 sa.sa_mask.__bits[0] = sv->sv_mask;
58 osap = osv != NULL ? &osa : NULL;
59 ret = __libc_sigaction(signo, sap, osap);
60 if (ret == 0 && osv != NULL) {
61 osv->sv_handler = osa.sa_handler;
62 osv->sv_flags = osa.sa_flags ^ SV_INTERRUPT;
63 osv->sv_mask = osa.sa_mask.__bits[0];
76 n = __libc_sigprocmask(SIG_SETMASK, &set, &oset);
79 return (oset.__bits[0]);
90 n = __libc_sigprocmask(SIG_BLOCK, &set, &oset);
93 return (oset.__bits[0]);
102 set.__bits[0] = mask;
103 return (__libc_sigsuspend(&set));
107 xsi_sigpause(int sig)
111 if (__libc_sigprocmask(SIG_BLOCK, NULL, &set) == -1)
113 if (sigdelset(&set, sig) == -1)
115 return (__libc_sigsuspend(&set));
124 if (sigaddset(&set, sig) == -1)
126 return (__libc_sigprocmask(SIG_BLOCK, &set, NULL));
134 bzero(&sa, sizeof(sa));
135 sa.sa_handler = SIG_IGN;
136 return (__libc_sigaction(sig, &sa, NULL));
145 if (sigaddset(&set, sig) == -1)
147 return (__libc_sigprocmask(SIG_UNBLOCK, &set, NULL));
151 (*sigset(int sig, void (*disp)(int)))(int)
154 struct sigaction sa, psa;
157 if (sigaddset(&set, sig) == -1)
159 if (__libc_sigprocmask(SIG_BLOCK, NULL, &pset) == -1)
161 if ((__sighandler_t *)disp == SIG_HOLD) {
162 if (__libc_sigprocmask(SIG_BLOCK, &set, &pset) == -1)
164 if (sigismember(&pset, sig))
167 if (__libc_sigaction(sig, NULL, &psa) == -1)
169 return (psa.sa_handler);
172 if (__libc_sigprocmask(SIG_UNBLOCK, &set, &pset) == -1)
176 bzero(&sa, sizeof(sa));
177 sa.sa_handler = disp;
178 if (__libc_sigaction(sig, &sa, &psa) == -1)
180 if (sigismember(&pset, sig))
183 return (psa.sa_handler);