1 /* $NetBSD: signalvar.h,v 1.32 2002/03/19 20:50:41 christos Exp $ */ 2 3 /* 4 * Copyright (c) 1991, 1993 5 * The Regents of the University of California. All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 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. All advertising materials mentioning features or use of this software 16 * must display the following acknowledgement: 17 * This product includes software developed by the University of 18 * California, Berkeley and its contributors. 19 * 4. Neither the name of the University nor the names of its contributors 20 * may be used to endorse or promote products derived from this software 21 * without specific prior written permission. 22 * 23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 * SUCH DAMAGE. 34 * 35 * @(#)signalvar.h 8.6 (Berkeley) 2/19/95 36 */ 37 38 #ifndef _SYS_SIGNALVAR_H_ /* tmp for user.h */ 39 #define _SYS_SIGNALVAR_H_ 40 41 /* 42 * Kernel signal definitions and data structures, 43 * not exported to user programs. 44 */ 45 46 /* 47 * Process signal actions, possibly shared between threads. 48 */ 49 struct sigacts { 50 struct sigaction sa_sigact[NSIG]; /* disposition of signals */ 51 52 int sa_refcnt; /* reference count */ 53 }; 54 55 /* 56 * Process signal state. 57 */ 58 struct sigctx { 59 /* This needs to be zeroed on fork */ 60 sigset_t ps_siglist; /* Signals arrived but not delivered. */ 61 char ps_sigcheck; /* May have deliverable signals. */ 62 63 /* This should be copied on fork */ 64 #define ps_startcopy ps_sigstk 65 struct sigaltstack ps_sigstk; /* sp & on stack state variable */ 66 sigset_t ps_oldmask; /* saved mask from before sigpause */ 67 int ps_flags; /* signal flags, below */ 68 int ps_sig; /* for core dump/debugger XXX */ 69 long ps_code; /* for core dump/debugger XXX */ 70 void *ps_sigcode; /* address of signal trampoline */ 71 sigset_t ps_sigmask; /* Current signal mask. */ 72 sigset_t ps_sigignore; /* Signals being ignored. */ 73 sigset_t ps_sigcatch; /* Signals being caught by user. */ 74 }; 75 76 /* signal flags */ 77 #define SAS_OLDMASK 0x01 /* need to restore mask before pause */ 78 79 /* additional signal action values, used only temporarily/internally */ 80 #define SIG_CATCH (void (*) __P((int)))2 81 #define SIG_HOLD (void (*) __P((int)))3 82 83 /* 84 * get signal action for process and signal; currently only for current process 85 */ 86 #define SIGACTION(p, sig) (p->p_sigacts->sa_sigact[(sig)]) 87 #define SIGACTION_PS(ps, sig) (ps->sa_sigact[(sig)]) 88 89 /* 90 * Mark that signals for a process need to be checked. 91 */ 92 #define CHECKSIGS(p) \ 93 do { \ 94 (p)->p_sigctx.ps_sigcheck = 1; \ 95 signotify(p); \ 96 } while (/* CONSTCOND */ 0) 97 98 /* 99 * Determine signal that should be delivered to process p, the current 100 * process, 0 if none. If there is a pending stop signal with default 101 * action, the process stops in issignal(). 102 */ 103 #define CURSIG(p) (p->p_sigctx.ps_sigcheck ? issignal(p) : 0) 104 105 /* 106 * Clear a pending signal from a process. 107 */ 108 #define CLRSIG(p, sig) sigdelset(&p->p_sigctx.ps_siglist, sig) 109 110 /* 111 * Signal properties and actions. 112 * The array below categorizes the signals and their default actions 113 * according to the following properties: 114 */ 115 #define SA_KILL 0x01 /* terminates process by default */ 116 #define SA_CORE 0x02 /* ditto and coredumps */ 117 #define SA_STOP 0x04 /* suspend process */ 118 #define SA_TTYSTOP 0x08 /* ditto, from tty */ 119 #define SA_IGNORE 0x10 /* ignore by default */ 120 #define SA_CONT 0x20 /* continue if suspended */ 121 #define SA_CANTMASK 0x40 /* non-maskable, catchable */ 122 #define SA_NORESET 0x80 /* not reset when caught */ 123 124 #ifdef SIGPROP 125 const int sigprop[NSIG] = { 126 0, /* 0 unused */ 127 SA_KILL, /* 1 SIGHUP */ 128 SA_KILL, /* 2 SIGINT */ 129 SA_KILL|SA_CORE, /* 3 SIGQUIT */ 130 SA_KILL|SA_CORE|SA_NORESET, /* 4 SIGILL */ 131 SA_KILL|SA_CORE|SA_NORESET, /* 5 SIGTRAP */ 132 SA_KILL|SA_CORE, /* 6 SIGABRT */ 133 SA_KILL|SA_CORE, /* 7 SIGEMT */ 134 SA_KILL|SA_CORE, /* 8 SIGFPE */ 135 SA_KILL|SA_CANTMASK, /* 9 SIGKILL */ 136 SA_KILL|SA_CORE, /* 10 SIGBUS */ 137 SA_KILL|SA_CORE, /* 11 SIGSEGV */ 138 SA_KILL|SA_CORE, /* 12 SIGSYS */ 139 SA_KILL, /* 13 SIGPIPE */ 140 SA_KILL, /* 14 SIGALRM */ 141 SA_KILL, /* 15 SIGTERM */ 142 SA_IGNORE, /* 16 SIGURG */ 143 SA_STOP|SA_CANTMASK, /* 17 SIGSTOP */ 144 SA_STOP|SA_TTYSTOP, /* 18 SIGTSTP */ 145 SA_IGNORE|SA_CONT, /* 19 SIGCONT */ 146 SA_IGNORE, /* 20 SIGCHLD */ 147 SA_STOP|SA_TTYSTOP, /* 21 SIGTTIN */ 148 SA_STOP|SA_TTYSTOP, /* 22 SIGTTOU */ 149 SA_IGNORE, /* 23 SIGIO */ 150 SA_KILL, /* 24 SIGXCPU */ 151 SA_KILL, /* 25 SIGXFSZ */ 152 SA_KILL, /* 26 SIGVTALRM */ 153 SA_KILL, /* 27 SIGPROF */ 154 SA_IGNORE, /* 28 SIGWINCH */ 155 SA_IGNORE, /* 29 SIGINFO */ 156 SA_KILL, /* 30 SIGUSR1 */ 157 SA_KILL, /* 31 SIGUSR2 */ 158 SA_IGNORE|SA_NORESET, /* 32 SIGPWR */ 159 SA_KILL, /* 33 SIGRTMIN + 0 */ 160 SA_KILL, /* 34 SIGRTMIN + 1 */ 161 SA_KILL, /* 35 SIGRTMIN + 2 */ 162 SA_KILL, /* 36 SIGRTMIN + 3 */ 163 SA_KILL, /* 37 SIGRTMIN + 4 */ 164 SA_KILL, /* 38 SIGRTMIN + 5 */ 165 SA_KILL, /* 39 SIGRTMIN + 6 */ 166 SA_KILL, /* 40 SIGRTMIN + 7 */ 167 SA_KILL, /* 41 SIGRTMIN + 8 */ 168 SA_KILL, /* 42 SIGRTMIN + 9 */ 169 SA_KILL, /* 43 SIGRTMIN + 10 */ 170 SA_KILL, /* 44 SIGRTMIN + 11 */ 171 SA_KILL, /* 45 SIGRTMIN + 12 */ 172 SA_KILL, /* 46 SIGRTMIN + 13 */ 173 SA_KILL, /* 47 SIGRTMIN + 14 */ 174 SA_KILL, /* 48 SIGRTMIN + 15 */ 175 SA_KILL, /* 49 SIGRTMIN + 16 */ 176 SA_KILL, /* 50 SIGRTMIN + 17 */ 177 SA_KILL, /* 51 SIGRTMIN + 18 */ 178 SA_KILL, /* 52 SIGRTMIN + 19 */ 179 SA_KILL, /* 53 SIGRTMIN + 20 */ 180 SA_KILL, /* 54 SIGRTMIN + 21 */ 181 SA_KILL, /* 55 SIGRTMIN + 22 */ 182 SA_KILL, /* 56 SIGRTMIN + 23 */ 183 SA_KILL, /* 57 SIGRTMIN + 24 */ 184 SA_KILL, /* 58 SIGRTMIN + 25 */ 185 SA_KILL, /* 59 SIGRTMIN + 26 */ 186 SA_KILL, /* 60 SIGRTMIN + 27 */ 187 SA_KILL, /* 61 SIGRTMIN + 28 */ 188 SA_KILL, /* 62 SIGRTMIN + 29 */ 189 SA_KILL, /* 63 SIGRTMIN + 30 */ 190 }; 191 #endif /* SIGPROP */ 192 193 #ifdef _KERNEL 194 195 extern sigset_t contsigmask, stopsigmask, sigcantmask; 196 197 struct vnode; 198 struct ucred; 199 200 /* 201 * Machine-independent functions: 202 */ 203 int coredump __P((struct proc *p)); 204 int coredump_netbsd __P((struct proc *p, struct vnode *vp, 205 struct ucred *cred)); 206 void execsigs __P((struct proc *p)); 207 void gsignal __P((int pgid, int sig)); 208 int issignal __P((struct proc *p)); 209 void pgsignal __P((struct pgrp *pgrp, int sig, int checkctty)); 210 void postsig __P((int sig)); 211 void psignal1 __P((struct proc *p, int sig, int dolock)); 212 #define psignal(p, sig) psignal1((p), (sig), 1) 213 #define sched_psignal(p, sig) psignal1((p), (sig), 0) 214 void siginit __P((struct proc *p)); 215 void trapsignal __P((struct proc *p, int sig, u_long code)); 216 void sigexit __P((struct proc *, int)); 217 void setsigvec __P((struct proc *, int, struct sigaction *)); 218 int killpg1 __P((struct proc *, int, int, int)); 219 220 int sigaction1 __P((struct proc *p, int signum, \ 221 const struct sigaction *nsa, struct sigaction *osa)); 222 int sigprocmask1 __P((struct proc *p, int how, \ 223 const sigset_t *nss, sigset_t *oss)); 224 void sigpending1 __P((struct proc *p, sigset_t *ss)); 225 int sigsuspend1 __P((struct proc *p, const sigset_t *ss)); 226 int sigaltstack1 __P((struct proc *p, \ 227 const struct sigaltstack *nss, struct sigaltstack *oss)); 228 int sigismasked __P((struct proc *, int)); 229 230 void signal_init __P((void)); 231 232 void sigactsinit __P((struct proc *, struct proc *, int)); 233 void sigactsunshare __P((struct proc *)); 234 void sigactsfree __P((struct proc *)); 235 236 /* 237 * Machine-dependent functions: 238 */ 239 void sendsig __P((sig_t action, int sig, sigset_t *returnmask, u_long code)); 240 struct core; 241 struct core32; 242 int cpu_coredump __P((struct proc *, struct vnode *, struct ucred *, 243 struct core *)); 244 int cpu_coredump32 __P((struct proc *, struct vnode *, struct ucred *, 245 struct core32 *)); 246 247 /* 248 * Compatibility functions. See compat/common/kern_sig_13.c. 249 */ 250 void native_sigset13_to_sigset __P((const sigset13_t *, sigset_t *)); 251 void native_sigset_to_sigset13 __P((const sigset_t *, sigset13_t *)); 252 void native_sigaction13_to_sigaction __P((const struct sigaction13 *, 253 struct sigaction *)); 254 void native_sigaction_to_sigaction13 __P((const struct sigaction *, 255 struct sigaction13 *)); 256 void native_sigaltstack13_to_sigaltstack __P((const struct sigaltstack13 *, 257 struct sigaltstack *)); 258 void native_sigaltstack_to_sigaltstack13 __P((const struct sigaltstack *, 259 struct sigaltstack13 *)); 260 #endif /* _KERNEL */ 261 #endif /* !_SYS_SIGNALVAR_H_ */ 262