1*c7ef0cfcSnicm /****************************************************************************
2*c7ef0cfcSnicm * Copyright 2020 Thomas E. Dickey *
3*c7ef0cfcSnicm * Copyright 1998-2002,2003 Free Software Foundation, Inc. *
4*c7ef0cfcSnicm * *
5*c7ef0cfcSnicm * Permission is hereby granted, free of charge, to any person obtaining a *
6*c7ef0cfcSnicm * copy of this software and associated documentation files (the *
7*c7ef0cfcSnicm * "Software"), to deal in the Software without restriction, including *
8*c7ef0cfcSnicm * without limitation the rights to use, copy, modify, merge, publish, *
9*c7ef0cfcSnicm * distribute, distribute with modifications, sublicense, and/or sell *
10*c7ef0cfcSnicm * copies of the Software, and to permit persons to whom the Software is *
11*c7ef0cfcSnicm * furnished to do so, subject to the following conditions: *
12*c7ef0cfcSnicm * *
13*c7ef0cfcSnicm * The above copyright notice and this permission notice shall be included *
14*c7ef0cfcSnicm * in all copies or substantial portions of the Software. *
15*c7ef0cfcSnicm * *
16*c7ef0cfcSnicm * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
17*c7ef0cfcSnicm * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
18*c7ef0cfcSnicm * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
19*c7ef0cfcSnicm * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
20*c7ef0cfcSnicm * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
21*c7ef0cfcSnicm * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
22*c7ef0cfcSnicm * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
23*c7ef0cfcSnicm * *
24*c7ef0cfcSnicm * Except as contained in this notice, the name(s) of the above copyright *
25*c7ef0cfcSnicm * holders shall not be used in advertising or otherwise to promote the *
26*c7ef0cfcSnicm * sale, use or other dealings in this Software without prior written *
27*c7ef0cfcSnicm * authorization. *
28*c7ef0cfcSnicm ****************************************************************************/
29*c7ef0cfcSnicm
30*c7ef0cfcSnicm /****************************************************************************
31*c7ef0cfcSnicm * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
32*c7ef0cfcSnicm * and: Eric S. Raymond <esr@snark.thyrsus.com> *
33*c7ef0cfcSnicm * and: Thomas E. Dickey 1996-2003 *
34*c7ef0cfcSnicm ****************************************************************************/
35*c7ef0cfcSnicm
36*c7ef0cfcSnicm /* This file provides sigaction() emulation using sigvec() */
37*c7ef0cfcSnicm /* Use only if this is non POSIX system */
38*c7ef0cfcSnicm
39*c7ef0cfcSnicm MODULE_ID("$Id: sigaction.c,v 1.6 2023/10/17 09:52:09 nicm Exp $")
40*c7ef0cfcSnicm
41*c7ef0cfcSnicm static int
_nc_sigaction(int sig,sigaction_t * sigact,sigaction_t * osigact)42*c7ef0cfcSnicm _nc_sigaction(int sig, sigaction_t * sigact, sigaction_t * osigact)
43*c7ef0cfcSnicm {
44*c7ef0cfcSnicm return sigvec(sig, sigact, osigact);
45*c7ef0cfcSnicm }
46*c7ef0cfcSnicm
47*c7ef0cfcSnicm static int
_nc_sigemptyset(sigset_t * mask)48*c7ef0cfcSnicm _nc_sigemptyset(sigset_t * mask)
49*c7ef0cfcSnicm {
50*c7ef0cfcSnicm *mask = 0;
51*c7ef0cfcSnicm return 0;
52*c7ef0cfcSnicm }
53*c7ef0cfcSnicm
54*c7ef0cfcSnicm static int
_nc_sigprocmask(int mode,sigset_t * mask,sigset_t * omask)55*c7ef0cfcSnicm _nc_sigprocmask(int mode, sigset_t * mask, sigset_t * omask)
56*c7ef0cfcSnicm {
57*c7ef0cfcSnicm sigset_t current = sigsetmask(0);
58*c7ef0cfcSnicm
59*c7ef0cfcSnicm if (omask)
60*c7ef0cfcSnicm *omask = current;
61*c7ef0cfcSnicm
62*c7ef0cfcSnicm if (mode == SIG_BLOCK)
63*c7ef0cfcSnicm current |= *mask;
64*c7ef0cfcSnicm else if (mode == SIG_UNBLOCK)
65*c7ef0cfcSnicm current &= ~*mask;
66*c7ef0cfcSnicm else if (mode == SIG_SETMASK)
67*c7ef0cfcSnicm current = *mask;
68*c7ef0cfcSnicm
69*c7ef0cfcSnicm sigsetmask(current);
70*c7ef0cfcSnicm return 0;
71*c7ef0cfcSnicm }
72*c7ef0cfcSnicm
73*c7ef0cfcSnicm static int
_nc_sigaddset(sigset_t * mask,int sig)74*c7ef0cfcSnicm _nc_sigaddset(sigset_t * mask, int sig)
75*c7ef0cfcSnicm {
76*c7ef0cfcSnicm *mask |= sigmask(sig);
77*c7ef0cfcSnicm return 0;
78*c7ef0cfcSnicm }
79*c7ef0cfcSnicm
80*c7ef0cfcSnicm /* not used in lib_tstp.c */
81*c7ef0cfcSnicm #if 0
82*c7ef0cfcSnicm static int
83*c7ef0cfcSnicm _nc_sigsuspend(sigset_t * mask)
84*c7ef0cfcSnicm {
85*c7ef0cfcSnicm return sigpause(*mask);
86*c7ef0cfcSnicm }
87*c7ef0cfcSnicm
88*c7ef0cfcSnicm static int
89*c7ef0cfcSnicm _nc_sigdelset(sigset_t * mask, int sig)
90*c7ef0cfcSnicm {
91*c7ef0cfcSnicm *mask &= ~sigmask(sig);
92*c7ef0cfcSnicm return 0;
93*c7ef0cfcSnicm }
94*c7ef0cfcSnicm
95*c7ef0cfcSnicm static int
96*c7ef0cfcSnicm _nc_sigismember(sigset_t * mask, int sig)
97*c7ef0cfcSnicm {
98*c7ef0cfcSnicm return (*mask & sigmask(sig)) != 0;
99*c7ef0cfcSnicm }
100*c7ef0cfcSnicm #endif
101