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