FreeBSD/Linux Kernel Cross Reference
sys/sys/signalvar.h
1 /* $NetBSD: signalvar.h,v 1.68 2006/11/01 09:46:14 yamt 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 all pending signal from a process.
115 */
116 #define CLRSIG(l) \
117 do { \
118 int _sg; \
119 while ((_sg = CURSIG(l)) != 0) \
120 sigdelset(&(l)->l_proc->p_sigctx.ps_siglist, _sg); \
121 } while (/*CONSTCOND*/0)
122
123 /*
124 * Signal properties and actions.
125 * The array below categorizes the signals and their default actions
126 * according to the following properties:
127 */
128 #define SA_KILL 0x01 /* terminates process by default */
129 #define SA_CORE 0x02 /* ditto and coredumps */
130 #define SA_STOP 0x04 /* suspend process */
131 #define SA_TTYSTOP 0x08 /* ditto, from tty */
132 #define SA_IGNORE 0x10 /* ignore by default */
133 #define SA_CONT 0x20 /* continue if suspended */
134 #define SA_CANTMASK 0x40 /* non-maskable, catchable */
135 #define SA_NORESET 0x80 /* not reset when caught */
136
137 #ifdef _KERNEL
138
139 #include <sys/systm.h> /* for copyin_t/copyout_t */
140
141 extern sigset_t contsigmask, stopsigmask, sigcantmask;
142
143 struct vnode;
144
145 /*
146 * Machine-independent functions:
147 */
148 int coredump(struct lwp *, const char *);
149 int coredump_netbsd(struct lwp *, void *);
150 void execsigs(struct proc *);
151 void gsignal(int, int);
152 void kgsignal(int, struct ksiginfo *, void *);
153 int issignal(struct lwp *);
154 void pgsignal(struct pgrp *, int, int);
155 void kpgsignal(struct pgrp *, struct ksiginfo *, void *, int);
156 void postsig(int);
157 void psignal(struct proc *, int);
158 void kpsignal(struct proc *, struct ksiginfo *, void *);
159 void child_psignal(struct proc *);
160 void siginit(struct proc *);
161 void trapsignal(struct lwp *, const struct ksiginfo *);
162 void sigexit(struct lwp *, int);
163 void killproc(struct proc *, const char *);
164 void setsigvec(struct proc *, int, struct sigaction *);
165 int killpg1(struct lwp *, struct ksiginfo *, int, int);
166 struct lwp *proc_unstop(struct proc *p);
167
168 int sigaction1(struct proc *, int, const struct sigaction *,
169 struct sigaction *, const void *, int);
170 int sigprocmask1(struct proc *, int, const sigset_t *, sigset_t *);
171 void sigpending1(struct proc *, sigset_t *);
172 int sigsuspend1(struct proc *, const sigset_t *);
173 int sigaltstack1(struct proc *, const struct sigaltstack *,
174 struct sigaltstack *);
175 int sigismasked(struct proc *, int);
176
177 void signal_init(void);
178
179 void sigactsinit(struct proc *, struct proc *, int);
180 void sigactsunshare(struct proc *);
181 void sigactsfree(struct sigacts *);
182
183 void kpsendsig(struct lwp *, const struct ksiginfo *, const sigset_t *);
184 siginfo_t *siginfo_alloc(int);
185 void siginfo_free(void *);
186
187 int __sigtimedwait1(struct lwp *, void *, register_t *, copyout_t,
188 copyin_t, copyout_t);
189
190 /*
191 * Machine-dependent functions:
192 */
193 void sendsig(const struct ksiginfo *, const sigset_t *);
194
195 #endif /* _KERNEL */
196
197 #ifdef _KERNEL
198 #ifdef SIGPROP
199 const int sigprop[NSIG] = {
200 0, /* 0 unused */
201 SA_KILL, /* 1 SIGHUP */
202 SA_KILL, /* 2 SIGINT */
203 SA_KILL|SA_CORE, /* 3 SIGQUIT */
204 SA_KILL|SA_CORE|SA_NORESET, /* 4 SIGILL */
205 SA_KILL|SA_CORE|SA_NORESET, /* 5 SIGTRAP */
206 SA_KILL|SA_CORE, /* 6 SIGABRT */
207 SA_KILL|SA_CORE, /* 7 SIGEMT */
208 SA_KILL|SA_CORE, /* 8 SIGFPE */
209 SA_KILL|SA_CANTMASK, /* 9 SIGKILL */
210 SA_KILL|SA_CORE, /* 10 SIGBUS */
211 SA_KILL|SA_CORE, /* 11 SIGSEGV */
212 SA_KILL|SA_CORE, /* 12 SIGSYS */
213 SA_KILL, /* 13 SIGPIPE */
214 SA_KILL, /* 14 SIGALRM */
215 SA_KILL, /* 15 SIGTERM */
216 SA_IGNORE, /* 16 SIGURG */
217 SA_STOP|SA_CANTMASK, /* 17 SIGSTOP */
218 SA_STOP|SA_TTYSTOP, /* 18 SIGTSTP */
219 SA_IGNORE|SA_CONT, /* 19 SIGCONT */
220 SA_IGNORE, /* 20 SIGCHLD */
221 SA_STOP|SA_TTYSTOP, /* 21 SIGTTIN */
222 SA_STOP|SA_TTYSTOP, /* 22 SIGTTOU */
223 SA_IGNORE, /* 23 SIGIO */
224 SA_KILL, /* 24 SIGXCPU */
225 SA_KILL, /* 25 SIGXFSZ */
226 SA_KILL, /* 26 SIGVTALRM */
227 SA_KILL, /* 27 SIGPROF */
228 SA_IGNORE, /* 28 SIGWINCH */
229 SA_IGNORE, /* 29 SIGINFO */
230 SA_KILL, /* 30 SIGUSR1 */
231 SA_KILL, /* 31 SIGUSR2 */
232 SA_IGNORE|SA_NORESET, /* 32 SIGPWR */
233 SA_KILL, /* 33 SIGRTMIN + 0 */
234 SA_KILL, /* 34 SIGRTMIN + 1 */
235 SA_KILL, /* 35 SIGRTMIN + 2 */
236 SA_KILL, /* 36 SIGRTMIN + 3 */
237 SA_KILL, /* 37 SIGRTMIN + 4 */
238 SA_KILL, /* 38 SIGRTMIN + 5 */
239 SA_KILL, /* 39 SIGRTMIN + 6 */
240 SA_KILL, /* 40 SIGRTMIN + 7 */
241 SA_KILL, /* 41 SIGRTMIN + 8 */
242 SA_KILL, /* 42 SIGRTMIN + 9 */
243 SA_KILL, /* 43 SIGRTMIN + 10 */
244 SA_KILL, /* 44 SIGRTMIN + 11 */
245 SA_KILL, /* 45 SIGRTMIN + 12 */
246 SA_KILL, /* 46 SIGRTMIN + 13 */
247 SA_KILL, /* 47 SIGRTMIN + 14 */
248 SA_KILL, /* 48 SIGRTMIN + 15 */
249 SA_KILL, /* 49 SIGRTMIN + 16 */
250 SA_KILL, /* 50 SIGRTMIN + 17 */
251 SA_KILL, /* 51 SIGRTMIN + 18 */
252 SA_KILL, /* 52 SIGRTMIN + 19 */
253 SA_KILL, /* 53 SIGRTMIN + 20 */
254 SA_KILL, /* 54 SIGRTMIN + 21 */
255 SA_KILL, /* 55 SIGRTMIN + 22 */
256 SA_KILL, /* 56 SIGRTMIN + 23 */
257 SA_KILL, /* 57 SIGRTMIN + 24 */
258 SA_KILL, /* 58 SIGRTMIN + 25 */
259 SA_KILL, /* 59 SIGRTMIN + 26 */
260 SA_KILL, /* 60 SIGRTMIN + 27 */
261 SA_KILL, /* 61 SIGRTMIN + 28 */
262 SA_KILL, /* 62 SIGRTMIN + 29 */
263 SA_KILL, /* 63 SIGRTMIN + 30 */
264 };
265 #undef SIGPROP
266 #else
267 extern const int sigprop[NSIG];
268 #endif /* SIGPROP */
269 #endif /* _KERNEL */
270 #endif /* !_SYS_SIGNALVAR_H_ */
Cache object: 0c0cc603b781e96478a3bae755dd8d77
|