1 /* $OpenBSD: signalvar.h,v 1.16 2007/02/06 18:42:37 art Exp $ */ 2 /* $NetBSD: signalvar.h,v 1.17 1996/04/22 01:23:31 christos Exp $ */ 3 4 /* 5 * Copyright (c) 1991, 1993 6 * The Regents of the University of California. All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 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. 19 * 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 30 * SUCH DAMAGE. 31 * 32 * @(#)signalvar.h 8.3 (Berkeley) 1/4/94 33 */ 34 35 #ifndef _SYS_SIGNALVAR_H_ /* tmp for user.h */ 36 #define _SYS_SIGNALVAR_H_ 37 38 /* 39 * Kernel signal definitions and data structures, 40 * not exported to user programs. 41 */ 42 43 /* 44 * Process signal actions and state, needed only within the process 45 * (not necessarily resident). 46 */ 47 struct sigacts { 48 sig_t ps_sigact[NSIG]; /* disposition of signals */ 49 sigset_t ps_catchmask[NSIG]; /* signals to be blocked */ 50 sigset_t ps_sigonstack; /* signals to take on sigstack */ 51 sigset_t ps_sigintr; /* signals that interrupt syscalls */ 52 sigset_t ps_sigreset; /* signals that reset when caught */ 53 sigset_t ps_siginfo; /* signals that provide siginfo */ 54 sigset_t ps_oldmask; /* saved mask from before sigpause */ 55 int ps_flags; /* signal flags, below */ 56 struct sigaltstack ps_sigstk; /* sp & on stack state variable */ 57 int ps_sig; /* for core dump/debugger XXX */ 58 long ps_code; /* for core dump/debugger XXX */ 59 int ps_type; /* for core dump/debugger XXX */ 60 union sigval ps_sigval; /* for core dump/debugger XXX */ 61 sigset_t ps_usertramp; /* SunOS compat; libc sigtramp XXX */ 62 int ps_refcnt; /* reference count */ 63 }; 64 65 /* signal flags */ 66 #define SAS_OLDMASK 0x01 /* need to restore mask before pause */ 67 #define SAS_ALTSTACK 0x02 /* have alternate signal stack */ 68 69 /* additional signal action values, used only temporarily/internally */ 70 #define SIG_CATCH (void (*)(int))2 71 #define SIG_HOLD (void (*)(int))3 72 73 /* 74 * get signal action for process and signal; currently only for current process 75 */ 76 #define SIGACTION(p, sig) (p->p_sigacts->ps_sigact[(sig)]) 77 78 /* 79 * Determine signal that should be delivered to process p, the current 80 * process, 0 if none. If there is a pending stop signal with default 81 * action, the process stops in issignal(). 82 */ 83 #define CURSIG(p) \ 84 (((p)->p_siglist == 0 || \ 85 (((p)->p_flag & P_TRACED) == 0 && \ 86 ((p)->p_siglist & ~(p)->p_sigmask) == 0)) ? \ 87 0 : issignal(p)) 88 89 /* 90 * Clear a pending signal from a process. 91 */ 92 #define CLRSIG(p, sig) atomic_clearbits_int(&(p)->p_siglist, sigmask(sig)) 93 94 /* 95 * Signal properties and actions. 96 * The array below categorizes the signals and their default actions 97 * according to the following properties: 98 */ 99 #define SA_KILL 0x01 /* terminates process by default */ 100 #define SA_CORE 0x02 /* ditto and coredumps */ 101 #define SA_STOP 0x04 /* suspend process */ 102 #define SA_TTYSTOP 0x08 /* ditto, from tty */ 103 #define SA_IGNORE 0x10 /* ignore by default */ 104 #define SA_CONT 0x20 /* continue if suspended */ 105 #define SA_CANTMASK 0x40 /* non-maskable, catchable */ 106 107 #ifdef SIGPROP 108 int sigprop[NSIG + 1] = { 109 0, /* unused */ 110 SA_KILL, /* SIGHUP */ 111 SA_KILL, /* SIGINT */ 112 SA_KILL|SA_CORE, /* SIGQUIT */ 113 SA_KILL|SA_CORE, /* SIGILL */ 114 SA_KILL|SA_CORE, /* SIGTRAP */ 115 SA_KILL|SA_CORE, /* SIGABRT */ 116 SA_KILL|SA_CORE, /* SIGEMT */ 117 SA_KILL|SA_CORE, /* SIGFPE */ 118 SA_KILL, /* SIGKILL */ 119 SA_KILL|SA_CORE, /* SIGBUS */ 120 SA_KILL|SA_CORE, /* SIGSEGV */ 121 SA_KILL|SA_CORE, /* SIGSYS */ 122 SA_KILL, /* SIGPIPE */ 123 SA_KILL, /* SIGALRM */ 124 SA_KILL, /* SIGTERM */ 125 SA_IGNORE, /* SIGURG */ 126 SA_STOP, /* SIGSTOP */ 127 SA_STOP|SA_TTYSTOP, /* SIGTSTP */ 128 SA_IGNORE|SA_CONT, /* SIGCONT */ 129 SA_IGNORE, /* SIGCHLD */ 130 SA_STOP|SA_TTYSTOP, /* SIGTTIN */ 131 SA_STOP|SA_TTYSTOP, /* SIGTTOU */ 132 SA_IGNORE, /* SIGIO */ 133 SA_KILL, /* SIGXCPU */ 134 SA_KILL, /* SIGXFSZ */ 135 SA_KILL, /* SIGVTALRM */ 136 SA_KILL, /* SIGPROF */ 137 SA_IGNORE, /* SIGWINCH */ 138 SA_IGNORE, /* SIGINFO */ 139 SA_KILL, /* SIGUSR1 */ 140 SA_KILL, /* SIGUSR2 */ 141 }; 142 143 #define contsigmask (sigmask(SIGCONT)) 144 #define stopsigmask (sigmask(SIGSTOP) | sigmask(SIGTSTP) | \ 145 sigmask(SIGTTIN) | sigmask(SIGTTOU)) 146 147 #endif /* SIGPROP */ 148 149 #define sigcantmask (sigmask(SIGKILL) | sigmask(SIGSTOP)) 150 151 #ifdef _KERNEL 152 /* 153 * Machine-independent functions: 154 */ 155 int coredump(struct proc *p); 156 void execsigs(struct proc *p); 157 void gsignal(int pgid, int sig); 158 void csignal(pid_t pgid, int signum, uid_t uid, uid_t euid); 159 int issignal(struct proc *p); 160 void pgsignal(struct pgrp *pgrp, int sig, int checkctty); 161 void postsig(int sig); 162 void psignal(struct proc *p, int sig); 163 void siginit(struct proc *p); 164 void trapsignal(struct proc *p, int sig, u_long code, int type, 165 union sigval val); 166 void sigexit(struct proc *, int); 167 void setsigvec(struct proc *, int, struct sigaction *); 168 int killpg1(struct proc *, int, int, int); 169 170 void signal_init(void); 171 172 struct sigacts *sigactsinit(struct proc *); 173 void sigactsshare(struct proc *, struct proc *); 174 void sigactsunshare(struct proc *); 175 void sigactsfree(struct proc *); 176 177 /* 178 * Machine-dependent functions: 179 */ 180 void sendsig(sig_t action, int sig, int returnmask, u_long code, 181 int type, union sigval val); 182 struct core; 183 struct vnode; 184 struct ucred; 185 int cpu_coredump(struct proc *, struct vnode *, struct ucred *, 186 struct core *); 187 #endif /* _KERNEL */ 188 #endif /* !_SYS_SIGNALVAR_H_ */