kern_sig.c (46381) | kern_sig.c (48621) |
---|---|
1/* 2 * Copyright (c) 1982, 1986, 1989, 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * (c) UNIX System Laboratories, Inc. 5 * All or some portions of this file are derived from material licensed 6 * to the University of California by American Telephone and Telegraph 7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 8 * the permission of UNIX System Laboratories, Inc. --- 22 unchanged lines hidden (view full) --- 31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * SUCH DAMAGE. 37 * 38 * @(#)kern_sig.c 8.7 (Berkeley) 4/18/94 | 1/* 2 * Copyright (c) 1982, 1986, 1989, 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * (c) UNIX System Laboratories, Inc. 5 * All or some portions of this file are derived from material licensed 6 * to the University of California by American Telephone and Telegraph 7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 8 * the permission of UNIX System Laboratories, Inc. --- 22 unchanged lines hidden (view full) --- 31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * SUCH DAMAGE. 37 * 38 * @(#)kern_sig.c 8.7 (Berkeley) 4/18/94 |
39 * $Id: kern_sig.c,v 1.55 1999/04/28 11:36:59 phk Exp $ | 39 * $Id: kern_sig.c,v 1.56 1999/05/03 23:57:22 billf Exp $ |
40 */ 41 42#include "opt_compat.h" 43#include "opt_ktrace.h" 44 45#define SIGPROP /* include signal properties table */ 46#include <sys/param.h> 47#include <sys/kernel.h> --- 73 unchanged lines hidden (view full) --- 121 register int signum; 122 int bit, error; 123 124 signum = uap->signum; 125 if (signum <= 0 || signum >= NSIG) 126 return (EINVAL); 127 sa = &vec; 128 if (uap->osa) { | 40 */ 41 42#include "opt_compat.h" 43#include "opt_ktrace.h" 44 45#define SIGPROP /* include signal properties table */ 46#include <sys/param.h> 47#include <sys/kernel.h> --- 73 unchanged lines hidden (view full) --- 121 register int signum; 122 int bit, error; 123 124 signum = uap->signum; 125 if (signum <= 0 || signum >= NSIG) 126 return (EINVAL); 127 sa = &vec; 128 if (uap->osa) { |
129 sa->sa_handler = ps->ps_sigact[signum]; 130 sa->sa_mask = ps->ps_catchmask[signum]; | |
131 bit = sigmask(signum); | 129 bit = sigmask(signum); |
130 if ((ps->ps_siginfo & bit) != 0) 131 sa->sa_sigaction = 132 (__siginfohandler_t *)ps->ps_sigact[signum]; 133 else 134 sa->sa_handler = ps->ps_sigact[signum]; 135 sa->sa_mask = ps->ps_catchmask[signum]; |
|
132 sa->sa_flags = 0; 133 if ((ps->ps_sigonstack & bit) != 0) 134 sa->sa_flags |= SA_ONSTACK; 135 if ((ps->ps_sigintr & bit) == 0) 136 sa->sa_flags |= SA_RESTART; 137 if ((ps->ps_sigreset & bit) != 0) 138 sa->sa_flags |= SA_RESETHAND; 139 if ((ps->ps_signodefer & bit) != 0) 140 sa->sa_flags |= SA_NODEFER; | 136 sa->sa_flags = 0; 137 if ((ps->ps_sigonstack & bit) != 0) 138 sa->sa_flags |= SA_ONSTACK; 139 if ((ps->ps_sigintr & bit) == 0) 140 sa->sa_flags |= SA_RESTART; 141 if ((ps->ps_sigreset & bit) != 0) 142 sa->sa_flags |= SA_RESETHAND; 143 if ((ps->ps_signodefer & bit) != 0) 144 sa->sa_flags |= SA_NODEFER; |
145 if ((ps->ps_siginfo & bit) != 0) 146 sa->sa_flags |= SA_SIGINFO; |
|
141 if (signum == SIGCHLD && p->p_procsig->ps_flag & P_NOCLDSTOP) 142 sa->sa_flags |= SA_NOCLDSTOP; 143 if (signum == SIGCHLD && p->p_procsig->ps_flag & P_NOCLDWAIT) 144 sa->sa_flags |= SA_NOCLDWAIT; 145 if ((error = copyout((caddr_t)sa, (caddr_t)uap->osa, 146 sizeof (vec)))) 147 return (error); 148 } 149 if (uap->nsa) { 150 if ((error = copyin((caddr_t)uap->nsa, (caddr_t)sa, 151 sizeof (vec)))) 152 return (error); 153 if ((signum == SIGKILL || signum == SIGSTOP) && | 147 if (signum == SIGCHLD && p->p_procsig->ps_flag & P_NOCLDSTOP) 148 sa->sa_flags |= SA_NOCLDSTOP; 149 if (signum == SIGCHLD && p->p_procsig->ps_flag & P_NOCLDWAIT) 150 sa->sa_flags |= SA_NOCLDWAIT; 151 if ((error = copyout((caddr_t)sa, (caddr_t)uap->osa, 152 sizeof (vec)))) 153 return (error); 154 } 155 if (uap->nsa) { 156 if ((error = copyin((caddr_t)uap->nsa, (caddr_t)sa, 157 sizeof (vec)))) 158 return (error); 159 if ((signum == SIGKILL || signum == SIGSTOP) && |
154 sa->sa_handler != SIG_DFL) | 160 ps->ps_sigact[signum] != SIG_DFL) |
155 return (EINVAL); 156 setsigvec(p, signum, sa); 157 } 158 return (0); 159} 160 161static void 162setsigvec(p, signum, sa) --- 4 unchanged lines hidden (view full) --- 167 register struct sigacts *ps = p->p_sigacts; 168 register int bit; 169 170 bit = sigmask(signum); 171 /* 172 * Change setting atomically. 173 */ 174 (void) splhigh(); | 161 return (EINVAL); 162 setsigvec(p, signum, sa); 163 } 164 return (0); 165} 166 167static void 168setsigvec(p, signum, sa) --- 4 unchanged lines hidden (view full) --- 173 register struct sigacts *ps = p->p_sigacts; 174 register int bit; 175 176 bit = sigmask(signum); 177 /* 178 * Change setting atomically. 179 */ 180 (void) splhigh(); |
175 ps->ps_sigact[signum] = sa->sa_handler; | |
176 ps->ps_catchmask[signum] = sa->sa_mask &~ sigcantmask; | 181 ps->ps_catchmask[signum] = sa->sa_mask &~ sigcantmask; |
182 if (sa->sa_flags & SA_SIGINFO) { 183 ps->ps_sigact[signum] = sa->sa_handler; 184 ps->ps_siginfo |= bit; 185 } else { 186 ps->ps_sigact[signum] = (__sighandler_t *)sa->sa_sigaction; 187 ps->ps_siginfo &= ~bit; 188 } |
|
177 if ((sa->sa_flags & SA_RESTART) == 0) 178 ps->ps_sigintr |= bit; 179 else 180 ps->ps_sigintr &= ~bit; 181 if (sa->sa_flags & SA_ONSTACK) 182 ps->ps_sigonstack |= bit; 183 else 184 ps->ps_sigonstack &= ~bit; --- 31 unchanged lines hidden (view full) --- 216 p->p_procsig->ps_flag &= ~P_NOCLDWAIT; 217 } 218 /* 219 * Set bit in p_sigignore for signals that are set to SIG_IGN, 220 * and for signals set to SIG_DFL where the default is to ignore. 221 * However, don't put SIGCONT in p_sigignore, 222 * as we have to restart the process. 223 */ | 189 if ((sa->sa_flags & SA_RESTART) == 0) 190 ps->ps_sigintr |= bit; 191 else 192 ps->ps_sigintr &= ~bit; 193 if (sa->sa_flags & SA_ONSTACK) 194 ps->ps_sigonstack |= bit; 195 else 196 ps->ps_sigonstack &= ~bit; --- 31 unchanged lines hidden (view full) --- 228 p->p_procsig->ps_flag &= ~P_NOCLDWAIT; 229 } 230 /* 231 * Set bit in p_sigignore for signals that are set to SIG_IGN, 232 * and for signals set to SIG_DFL where the default is to ignore. 233 * However, don't put SIGCONT in p_sigignore, 234 * as we have to restart the process. 235 */ |
224 if (sa->sa_handler == SIG_IGN || 225 (sigprop[signum] & SA_IGNORE && sa->sa_handler == SIG_DFL)) { | 236 if (ps->ps_sigact[signum] == SIG_IGN || 237 (sigprop[signum] & SA_IGNORE && ps->ps_sigact[signum] == SIG_DFL)) { |
226 p->p_siglist &= ~bit; /* never to be seen again */ 227 if (signum != SIGCONT) 228 p->p_sigignore |= bit; /* easier in psignal */ 229 p->p_sigcatch &= ~bit; 230 } else { 231 p->p_sigignore &= ~bit; | 238 p->p_siglist &= ~bit; /* never to be seen again */ 239 if (signum != SIGCONT) 240 p->p_sigignore |= bit; /* easier in psignal */ 241 p->p_sigcatch &= ~bit; 242 } else { 243 p->p_sigignore &= ~bit; |
232 if (sa->sa_handler == SIG_DFL) | 244 if (ps->ps_sigact[signum] == SIG_DFL) |
233 p->p_sigcatch &= ~bit; 234 else 235 p->p_sigcatch |= bit; 236 } 237 (void) spl0(); 238} 239 240/* --- 141 unchanged lines hidden (view full) --- 382 if ((ps->ps_sigonstack & bit) != 0) 383 sv->sv_flags |= SV_ONSTACK; 384 if ((ps->ps_sigintr & bit) != 0) 385 sv->sv_flags |= SV_INTERRUPT; 386 if ((ps->ps_sigreset & bit) != 0) 387 sv->sv_flags |= SV_RESETHAND; 388 if ((ps->ps_signodefer & bit) != 0) 389 sv->sv_flags |= SV_NODEFER; | 245 p->p_sigcatch &= ~bit; 246 else 247 p->p_sigcatch |= bit; 248 } 249 (void) spl0(); 250} 251 252/* --- 141 unchanged lines hidden (view full) --- 394 if ((ps->ps_sigonstack & bit) != 0) 395 sv->sv_flags |= SV_ONSTACK; 396 if ((ps->ps_sigintr & bit) != 0) 397 sv->sv_flags |= SV_INTERRUPT; 398 if ((ps->ps_sigreset & bit) != 0) 399 sv->sv_flags |= SV_RESETHAND; 400 if ((ps->ps_signodefer & bit) != 0) 401 sv->sv_flags |= SV_NODEFER; |
402 if ((ps->ps_siginfo & bit) != 0) 403 sv->sv_flags |= SV_SIGINFO; |
|
390#ifndef COMPAT_SUNOS 391 if (signum == SIGCHLD && p->p_procsig->ps_flag & P_NOCLDSTOP) 392 sv->sv_flags |= SV_NOCLDSTOP; 393#endif 394 if ((error = copyout((caddr_t)sv, (caddr_t)uap->osv, 395 sizeof (vec)))) 396 return (error); 397 } --- 986 unchanged lines hidden --- | 404#ifndef COMPAT_SUNOS 405 if (signum == SIGCHLD && p->p_procsig->ps_flag & P_NOCLDSTOP) 406 sv->sv_flags |= SV_NOCLDSTOP; 407#endif 408 if ((error = copyout((caddr_t)sv, (caddr_t)uap->osv, 409 sizeof (vec)))) 410 return (error); 411 } --- 986 unchanged lines hidden --- |