| Commit | Line | Data |
|---|---|---|
| 984263bc MD |
1 | /* |
| 2 | * Copyright (c) 1991, 1993 | |
| 3 | * The Regents of the University of California. All rights reserved. | |
| 4 | * | |
| 5 | * Redistribution and use in source and binary forms, with or without | |
| 6 | * modification, are permitted provided that the following conditions | |
| 7 | * are met: | |
| 8 | * 1. Redistributions of source code must retain the above copyright | |
| 9 | * notice, this list of conditions and the following disclaimer. | |
| 10 | * 2. Redistributions in binary form must reproduce the above copyright | |
| 11 | * notice, this list of conditions and the following disclaimer in the | |
| 12 | * documentation and/or other materials provided with the distribution. | |
| 13 | * 3. All advertising materials mentioning features or use of this software | |
| 14 | * must display the following acknowledgement: | |
| 15 | * This product includes software developed by the University of | |
| 16 | * California, Berkeley and its contributors. | |
| 17 | * 4. Neither the name of the University nor the names of its contributors | |
| 18 | * may be used to endorse or promote products derived from this software | |
| 19 | * without specific prior written permission. | |
| 20 | * | |
| 21 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | |
| 22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
| 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
| 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
| 25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
| 26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
| 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
| 28 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
| 29 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
| 30 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
| 31 | * SUCH DAMAGE. | |
| 32 | * | |
| 33 | * @(#)signalvar.h 8.6 (Berkeley) 2/19/95 | |
| 34 | * $FreeBSD: src/sys/sys/signalvar.h,v 1.34.2.1 2000/05/16 06:58:05 dillon Exp $ | |
| 35 | */ | |
| 36 | ||
| 37 | #ifndef _SYS_SIGNALVAR_H_ /* tmp for user.h */ | |
| 38 | #define _SYS_SIGNALVAR_H_ | |
| 39 | ||
| 05220613 MD |
40 | /* |
| 41 | * Don't bring in the entire bleeding include set if we aren't the kernel. | |
| 42 | * Userland is not allowed to bring in sys/proc.h except under special | |
| 43 | * circumstances (e.g. sys/user.h) | |
| 44 | */ | |
| 984263bc | 45 | #include <sys/signal.h> |
| 05220613 | 46 | #ifdef _KERNEL |
| 984263bc | 47 | #include <sys/proc.h> |
| 8a8d5d85 | 48 | #include <machine/lock.h> |
| 05220613 | 49 | #endif |
| 984263bc MD |
50 | |
| 51 | /* | |
| 52 | * Kernel signal definitions and data structures, | |
| 53 | * not exported to user programs. | |
| 54 | */ | |
| 55 | ||
| 56 | /* | |
| 57 | * Process signal actions and state, needed only within the process | |
| 58 | * (not necessarily resident). | |
| 59 | */ | |
| 60 | struct sigacts { | |
| b1b4e5a6 | 61 | sig_t ps_sigact[_SIG_MAXSIG]; /* disposition of signals */ |
| 984263bc | 62 | sigset_t ps_catchmask[_SIG_MAXSIG]; /* signals to be blocked */ |
| b1b4e5a6 SS |
63 | sigset_t ps_sigignore; /* Signals being ignored. */ |
| 64 | sigset_t ps_sigcatch; /* Signals being caught by user. */ | |
| 984263bc MD |
65 | sigset_t ps_sigonstack; /* signals to take on sigstack */ |
| 66 | sigset_t ps_sigintr; /* signals that interrupt syscalls */ | |
| 67 | sigset_t ps_sigreset; /* signals that reset when caught */ | |
| 68 | sigset_t ps_signodefer; /* signals not masked while handled */ | |
| 69 | sigset_t ps_siginfo; /* signals that want SA_SIGINFO args */ | |
| 984263bc | 70 | sigset_t ps_usertramp; /* SunOS compat; libc sigtramp XXX */ |
| 0d6e2d63 | 71 | unsigned int ps_refcnt; |
| b1b4e5a6 | 72 | int ps_flag; |
| 984263bc MD |
73 | }; |
| 74 | ||
| 984263bc MD |
75 | /* additional signal action values, used only temporarily/internally */ |
| 76 | #define SIG_CATCH ((__sighandler_t *)2) | |
| 77 | #define SIG_HOLD ((__sighandler_t *)3) | |
| 78 | ||
| 05220613 MD |
79 | #ifdef _KERNEL |
| 80 | ||
| 984263bc MD |
81 | /* |
| 82 | * get signal action for process and signal; currently only for current process | |
| 83 | */ | |
| 84 | #define SIGACTION(p, sig) (p->p_sigacts->ps_sigact[_SIG_IDX(sig)]) | |
| 85 | ||
| 05220613 MD |
86 | #endif |
| 87 | ||
| 984263bc MD |
88 | /* |
| 89 | * sigset_t manipulation macros | |
| 90 | */ | |
| 91 | #define SIGADDSET(set, signo) \ | |
| 92 | (set).__bits[_SIG_WORD(signo)] |= _SIG_BIT(signo) | |
| 93 | ||
| 94 | #define SIGDELSET(set, signo) \ | |
| 95 | (set).__bits[_SIG_WORD(signo)] &= ~_SIG_BIT(signo) | |
| 96 | ||
| 97 | #define SIGEMPTYSET(set) \ | |
| 98 | do { \ | |
| 99 | int __i; \ | |
| 100 | for (__i = 0; __i < _SIG_WORDS; __i++) \ | |
| 101 | (set).__bits[__i] = 0; \ | |
| 102 | } while (0) | |
| 103 | ||
| 104 | #define SIGFILLSET(set) \ | |
| 105 | do { \ | |
| 106 | int __i; \ | |
| 107 | for (__i = 0; __i < _SIG_WORDS; __i++) \ | |
| 108 | (set).__bits[__i] = ~(unsigned int)0; \ | |
| 109 | } while (0) | |
| 110 | ||
| 111 | #define SIGISMEMBER(set, signo) \ | |
| 112 | ((set).__bits[_SIG_WORD(signo)] & _SIG_BIT(signo)) | |
| 113 | ||
| 114 | #define SIGISEMPTY(set) __sigisempty(&(set)) | |
| 115 | #define SIGNOTEMPTY(set) (!__sigisempty(&(set))) | |
| 116 | ||
| 117 | #define SIGSETEQ(set1, set2) __sigseteq(&(set1), &(set2)) | |
| 118 | #define SIGSETNEQ(set1, set2) (!__sigseteq(&(set1), &(set2))) | |
| 119 | ||
| 120 | #define SIGSETOR(set1, set2) \ | |
| 121 | do { \ | |
| 122 | int __i; \ | |
| 123 | for (__i = 0; __i < _SIG_WORDS; __i++) \ | |
| 124 | (set1).__bits[__i] |= (set2).__bits[__i]; \ | |
| 125 | } while (0) | |
| 126 | ||
| 127 | #define SIGSETAND(set1, set2) \ | |
| 128 | do { \ | |
| 129 | int __i; \ | |
| 130 | for (__i = 0; __i < _SIG_WORDS; __i++) \ | |
| 131 | (set1).__bits[__i] &= (set2).__bits[__i]; \ | |
| 132 | } while (0) | |
| 133 | ||
| 134 | #define SIGSETNAND(set1, set2) \ | |
| 135 | do { \ | |
| 136 | int __i; \ | |
| 137 | for (__i = 0; __i < _SIG_WORDS; __i++) \ | |
| 138 | (set1).__bits[__i] &= ~(set2).__bits[__i]; \ | |
| 139 | } while (0) | |
| 140 | ||
| 984263bc MD |
141 | #define SIG_CANTMASK(set) \ |
| 142 | SIGDELSET(set, SIGKILL), SIGDELSET(set, SIGSTOP) | |
| 143 | ||
| 144 | #define SIG_STOPSIGMASK(set) \ | |
| 145 | SIGDELSET(set, SIGSTOP), SIGDELSET(set, SIGTSTP), \ | |
| 146 | SIGDELSET(set, SIGTTIN), SIGDELSET(set, SIGTTOU) | |
| 147 | ||
| 148 | #define SIG_CONTSIGMASK(set) \ | |
| 149 | SIGDELSET(set, SIGCONT) | |
| 150 | ||
| 151 | #define sigcantmask (sigmask(SIGKILL) | sigmask(SIGSTOP)) | |
| 152 | ||
| 984263bc MD |
153 | static __inline int |
| 154 | __sigisempty(sigset_t *set) | |
| 155 | { | |
| 156 | int i; | |
| 157 | ||
| 158 | for (i = 0; i < _SIG_WORDS; i++) { | |
| 159 | if (set->__bits[i]) | |
| 160 | return (0); | |
| 161 | } | |
| 162 | return (1); | |
| 163 | } | |
| 164 | ||
| 165 | static __inline int | |
| 166 | __sigseteq(sigset_t *set1, sigset_t *set2) | |
| 167 | { | |
| 168 | int i; | |
| 169 | ||
| 170 | for (i = 0; i < _SIG_WORDS; i++) { | |
| 171 | if (set1->__bits[i] != set2->__bits[i]) | |
| 172 | return (0); | |
| 173 | } | |
| 174 | return (1); | |
| 175 | } | |
| 176 | ||
| 177 | #ifdef _KERNEL | |
| 178 | ||
| 9d63d5c0 MD |
179 | typedef void (*proc_func_t)(struct proc *); |
| 180 | ||
| 984263bc MD |
181 | struct pgrp; |
| 182 | struct proc; | |
| 183 | struct sigio; | |
| 184 | ||
| 185 | extern int sugid_coredump; /* Sysctl variable kern.sugid_coredump */ | |
| 186 | ||
| 187 | /* | |
| 188 | * Machine-independent functions: | |
| 189 | */ | |
| b153f746 RG |
190 | void execsigs (struct proc *p); |
| 191 | void gsignal (int pgid, int sig); | |
| e473f776 | 192 | int issignal (struct lwp *lp, int maytrace); |
| 08f2f1bb | 193 | int iscaught (struct lwp *p); |
| b153f746 RG |
194 | void killproc (struct proc *p, char *why); |
| 195 | void pgsigio (struct sigio *, int signum, int checkctty); | |
| 196 | void pgsignal (struct pgrp *pgrp, int sig, int checkctty); | |
| 197 | void postsig (int sig); | |
| 84204577 | 198 | void ksignal (struct proc *p, int sig); |
| 7278a846 | 199 | void lwpsignal (struct proc *p, struct lwp *lp, int sig); |
| b153f746 | 200 | void siginit (struct proc *p); |
| 08f2f1bb | 201 | void trapsignal (struct lwp *p, int sig, u_long code); |
| 984263bc MD |
202 | |
| 203 | /* | |
| 204 | * Machine-dependent functions: | |
| 205 | */ | |
| b153f746 | 206 | void sendsig (sig_t action, int sig, sigset_t *retmask, u_long code); |
| b276424c | 207 | void sigexit (struct lwp *lp, int sig); |
| 7d20a8ff | 208 | int checkpoint_signal_handler(struct lwp *p); |
| 984263bc | 209 | |
| 984263bc MD |
210 | #endif /* _KERNEL */ |
| 211 | ||
| 212 | #endif /* !_SYS_SIGNALVAR_H_ */ |