]>
Commit | Line | Data |
---|---|---|
1c79356b | 1 | /* |
5d5c5d0d A |
2 | * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved. |
3 | * | |
2d21ac55 | 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ |
0a7de745 | 5 | * |
2d21ac55 A |
6 | * This file contains Original Code and/or Modifications of Original Code |
7 | * as defined in and that are subject to the Apple Public Source License | |
8 | * Version 2.0 (the 'License'). You may not use this file except in | |
9 | * compliance with the License. The rights granted to you under the License | |
10 | * may not be used to create, or enable the creation or redistribution of, | |
11 | * unlawful or unlicensed copies of an Apple operating system, or to | |
12 | * circumvent, violate, or enable the circumvention or violation of, any | |
13 | * terms of an Apple operating system software license agreement. | |
0a7de745 | 14 | * |
2d21ac55 A |
15 | * Please obtain a copy of the License at |
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. | |
0a7de745 | 17 | * |
2d21ac55 A |
18 | * The Original Code and all software distributed under the License are |
19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
8f6c56a5 A |
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
2d21ac55 A |
22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. |
23 | * Please see the License for the specific language governing rights and | |
24 | * limitations under the License. | |
0a7de745 | 25 | * |
2d21ac55 | 26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ |
1c79356b A |
27 | */ |
28 | /* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */ | |
29 | /* | |
30 | * Copyright (c) 1991, 1993 | |
31 | * The Regents of the University of California. All rights reserved. | |
32 | * | |
33 | * Redistribution and use in source and binary forms, with or without | |
34 | * modification, are permitted provided that the following conditions | |
35 | * are met: | |
36 | * 1. Redistributions of source code must retain the above copyright | |
37 | * notice, this list of conditions and the following disclaimer. | |
38 | * 2. Redistributions in binary form must reproduce the above copyright | |
39 | * notice, this list of conditions and the following disclaimer in the | |
40 | * documentation and/or other materials provided with the distribution. | |
41 | * 3. All advertising materials mentioning features or use of this software | |
42 | * must display the following acknowledgement: | |
43 | * This product includes software developed by the University of | |
44 | * California, Berkeley and its contributors. | |
45 | * 4. Neither the name of the University nor the names of its contributors | |
46 | * may be used to endorse or promote products derived from this software | |
47 | * without specific prior written permission. | |
48 | * | |
49 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | |
50 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
51 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
52 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
53 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
54 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
55 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
56 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
57 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
58 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
59 | * SUCH DAMAGE. | |
60 | * | |
61 | * @(#)signalvar.h 8.3 (Berkeley) 1/4/94 | |
62 | */ | |
63 | ||
0a7de745 A |
64 | #ifndef _SYS_SIGNALVAR_H_ /* tmp for user.h */ |
65 | #define _SYS_SIGNALVAR_H_ | |
1c79356b | 66 | |
9bccf70c A |
67 | #include <sys/appleapiopts.h> |
68 | ||
91447636 | 69 | #ifdef BSD_KERNEL_PRIVATE |
d9a64523 A |
70 | |
71 | #include <stdatomic.h> | |
72 | ||
1c79356b A |
73 | /* |
74 | * Kernel signal definitions and data structures, | |
75 | * not exported to user programs. | |
76 | */ | |
77 | ||
78 | /* | |
79 | * Process signal actions and state, needed only within the process | |
80 | * (not necessarily resident). | |
81 | */ | |
0a7de745 A |
82 | struct sigacts { |
83 | user_addr_t ps_sigact[NSIG]; /* disposition of signals */ | |
84 | user_addr_t ps_trampact[NSIG]; /* disposition of signals */ | |
85 | sigset_t ps_catchmask[NSIG]; /* signals to be blocked */ | |
86 | sigset_t ps_sigonstack; /* signals to take on sigstack */ | |
87 | sigset_t ps_sigintr; /* signals that interrupt syscalls */ | |
88 | sigset_t ps_sigreset; /* signals that reset when caught */ | |
89 | sigset_t ps_signodefer; /* signals not masked while handled */ | |
90 | sigset_t ps_siginfo; /* signals that want SA_SIGINFO args */ | |
91 | sigset_t ps_oldmask; /* saved mask from before sigpause */ | |
d9a64523 A |
92 | user_addr_t ps_sigreturn_token; /* random token used to validate sigreturn arguments */ |
93 | _Atomic uint32_t ps_sigreturn_validation; /* sigreturn argument validation state */ | |
0a7de745 | 94 | int ps_flags; /* signal flags, below */ |
0a7de745 A |
95 | int ps_sig; /* for core dump/debugger XXX */ |
96 | int ps_code; /* for core dump/debugger XXX */ | |
97 | int ps_addr; /* for core dump/debugger XXX */ | |
1c79356b A |
98 | }; |
99 | ||
100 | /* signal flags */ | |
0a7de745 A |
101 | #define SAS_OLDMASK 0x01 /* need to restore mask before pause */ |
102 | #define SAS_ALTSTACK 0x02 /* have alternate signal stack */ | |
1c79356b | 103 | |
91447636 A |
104 | /* |
105 | * Additional signal action values, used only temporarily/internally; these | |
106 | * values should be non-intersecting with values defined in signal.h, e.g.: | |
107 | * SIG_IGN, SIG_DFL, SIG_ERR, SIG_IGN. | |
108 | */ | |
0a7de745 A |
109 | #define KERN_SIG_CATCH CAST_USER_ADDR_T(2) |
110 | #define KERN_SIG_HOLD CAST_USER_ADDR_T(3) | |
111 | #define KERN_SIG_WAIT CAST_USER_ADDR_T(4) | |
1c79356b | 112 | |
d9a64523 A |
113 | /* Values for ps_sigreturn_validation */ |
114 | #define PS_SIGRETURN_VALIDATION_DEFAULT 0x0u | |
115 | #define PS_SIGRETURN_VALIDATION_ENABLED 0x1u | |
116 | #define PS_SIGRETURN_VALIDATION_DISABLED 0x2u | |
117 | ||
1c79356b A |
118 | /* |
119 | * get signal action for process and signal; currently only for current process | |
120 | */ | |
0a7de745 | 121 | #define SIGACTION(p, sig) (p->p_sigacts->ps_sigact[(sig)]) |
1c79356b | 122 | |
1c79356b A |
123 | /* |
124 | * Check for per-process and per thread signals. | |
125 | */ | |
0a7de745 A |
126 | #define SHOULDissignal(p, uthreadp) \ |
127 | (((uthreadp)->uu_siglist) \ | |
9bccf70c | 128 | & ~((((uthreadp)->uu_sigmask) \ |
2d21ac55 | 129 | | (((p)->p_lflag & P_LTRACED) ? 0 : (p)->p_sigignore)) \ |
1c79356b A |
130 | & ~sigcantmask)) |
131 | ||
132 | /* | |
0a7de745 | 133 | * Check for signals and per-thread signals. |
1c79356b A |
134 | * Use in trap() and syscall() before |
135 | * exiting kernel. | |
136 | */ | |
0a7de745 A |
137 | #define CHECK_SIGNALS(p, thread, uthreadp) \ |
138 | (!thread_should_halt(thread) \ | |
1c79356b A |
139 | && (SHOULDissignal(p,uthreadp))) |
140 | ||
1c79356b A |
141 | /* |
142 | * Signal properties and actions. | |
143 | * The array below categorizes the signals and their default actions | |
144 | * according to the following properties: | |
145 | */ | |
0a7de745 A |
146 | #define SA_KILL 0x01 /* terminates process by default */ |
147 | #define SA_CORE 0x02 /* ditto and coredumps */ | |
148 | #define SA_STOP 0x04 /* suspend process */ | |
149 | #define SA_TTYSTOP 0x08 /* ditto, from tty */ | |
150 | #define SA_IGNORE 0x10 /* ignore by default */ | |
151 | #define SA_CONT 0x20 /* continue if suspended */ | |
152 | #define SA_CANTMASK 0x40 /* non-maskable, catchable */ | |
153 | ||
154 | #ifdef SIGPROP | |
39037602 | 155 | int sigprop[NSIG] = { |
0a7de745 A |
156 | 0, /* unused */ |
157 | SA_KILL, /* SIGHUP */ | |
158 | SA_KILL, /* SIGINT */ | |
159 | SA_KILL | SA_CORE, /* SIGQUIT */ | |
160 | SA_KILL | SA_CORE, /* SIGILL */ | |
161 | SA_KILL | SA_CORE, /* SIGTRAP */ | |
162 | SA_KILL | SA_CORE, /* SIGABRT */ | |
163 | SA_KILL | SA_CORE, /* SIGEMT */ | |
164 | SA_KILL | SA_CORE, /* SIGFPE */ | |
165 | SA_KILL, /* SIGKILL */ | |
166 | SA_KILL | SA_CORE, /* SIGBUS */ | |
167 | SA_KILL | SA_CORE, /* SIGSEGV */ | |
168 | SA_KILL | SA_CORE, /* SIGSYS */ | |
169 | SA_KILL, /* SIGPIPE */ | |
170 | SA_KILL, /* SIGALRM */ | |
171 | SA_KILL, /* SIGTERM */ | |
172 | SA_IGNORE, /* SIGURG */ | |
173 | SA_STOP, /* SIGSTOP */ | |
174 | SA_STOP | SA_TTYSTOP, /* SIGTSTP */ | |
175 | SA_IGNORE | SA_CONT, /* SIGCONT */ | |
176 | SA_IGNORE, /* SIGCHLD */ | |
177 | SA_STOP | SA_TTYSTOP, /* SIGTTIN */ | |
178 | SA_STOP | SA_TTYSTOP, /* SIGTTOU */ | |
179 | SA_IGNORE, /* SIGIO */ | |
180 | SA_KILL, /* SIGXCPU */ | |
181 | SA_KILL, /* SIGXFSZ */ | |
182 | SA_KILL, /* SIGVTALRM */ | |
183 | SA_KILL, /* SIGPROF */ | |
184 | SA_IGNORE, /* SIGWINCH */ | |
185 | SA_IGNORE, /* SIGINFO */ | |
186 | SA_KILL, /* SIGUSR1 */ | |
187 | SA_KILL, /* SIGUSR2 */ | |
1c79356b A |
188 | }; |
189 | ||
0a7de745 A |
190 | #define contsigmask (sigmask(SIGCONT)) |
191 | #define stopsigmask (sigmask(SIGSTOP) | sigmask(SIGTSTP) | \ | |
192 | sigmask(SIGTTIN) | sigmask(SIGTTOU)) | |
1c79356b A |
193 | |
194 | #endif /* SIGPROP */ | |
195 | ||
0a7de745 | 196 | #define sigcantmask (sigmask(SIGKILL) | sigmask(SIGSTOP)) |
1c79356b | 197 | |
3e170ce0 | 198 | #define SIGRESTRICTMASK (sigmask(SIGILL) | sigmask(SIGTRAP) | sigmask(SIGABRT) | \ |
0a7de745 A |
199 | sigmask(SIGFPE) | sigmask(SIGBUS) | sigmask(SIGSEGV) | \ |
200 | sigmask(SIGSYS)) | |
3e170ce0 A |
201 | |
202 | extern unsigned sigrestrict_arg; | |
203 | ||
1c79356b A |
204 | /* |
205 | * Machine-independent functions: | |
206 | */ | |
3e170ce0 | 207 | |
0a7de745 A |
208 | void execsigs(struct proc *p, thread_t thread); |
209 | void gsignal(int pgid, int sig); | |
210 | int issignal_locked(struct proc *p); | |
211 | int CURSIG(struct proc *p); | |
b0d623f7 | 212 | int clear_procsiglist(struct proc *p, int bit, int in_signalstart); |
91447636 | 213 | int set_procsigmask(struct proc *p, int bit); |
0a7de745 A |
214 | void postsig_locked(int sig); |
215 | void siginit(struct proc *p); | |
216 | void trapsignal(struct proc *p, int sig, unsigned code); | |
217 | void pt_setrunnable(struct proc *p); | |
218 | int hassigprop(int sig, int prop); | |
3e170ce0 | 219 | int setsigvec(proc_t, thread_t, int signum, struct __kern_sigaction *, boolean_t in_sigstart); |
1c79356b | 220 | |
39037602 | 221 | struct os_reason; |
1c79356b A |
222 | /* |
223 | * Machine-dependent functions: | |
224 | */ | |
0a7de745 | 225 | void sendsig(struct proc *, /*sig_t*/ user_addr_t action, int sig, |
cb323159 | 226 | int returnmask, uint32_t code, sigset_t siginfo); |
0a7de745 A |
227 | |
228 | void psignal(struct proc *p, int sig); | |
229 | void psignal_with_reason(struct proc *p, int sig, struct os_reason *signal_reason); | |
230 | void psignal_locked(struct proc *, int); | |
231 | void psignal_try_thread(proc_t, thread_t, int signum); | |
232 | void psignal_try_thread_with_reason(proc_t, thread_t, int, struct os_reason*); | |
233 | void psignal_thread_with_reason(proc_t, thread_t, int, struct os_reason*); | |
234 | void psignal_uthread(thread_t, int); | |
235 | void pgsignal(struct pgrp *pgrp, int sig, int checkctty); | |
236 | void tty_pgsignal(struct tty * tp, int sig, int checkctty); | |
237 | void threadsignal(thread_t sig_actthread, int signum, | |
238 | mach_exception_code_t code, boolean_t set_exitreason); | |
239 | int thread_issignal(proc_t p, thread_t th, sigset_t mask); | |
240 | void psignal_vfork(struct proc *p, task_t new_task, thread_t thread, | |
241 | int signum); | |
39037602 | 242 | void psignal_vfork_with_reason(proc_t p, task_t new_task, thread_t thread, |
0a7de745 A |
243 | int signum, struct os_reason *signal_reason); |
244 | void signal_setast(thread_t sig_actthread); | |
245 | void pgsigio(pid_t pgid, int signalnum); | |
91447636 | 246 | |
2d21ac55 A |
247 | void sig_lock_to_exit(struct proc *p); |
248 | int sig_try_locked(struct proc *p); | |
91447636 | 249 | |
0a7de745 | 250 | #endif /* BSD_KERNEL_PRIVATE */ |
9bccf70c | 251 | |
cb323159 A |
252 | #if defined(KERNEL_PRIVATE) |
253 | /* Forward-declare these for consumers of the SDK that don't know about BSD types */ | |
254 | struct proc; | |
cb323159 | 255 | struct os_reason; |
f427ee49 | 256 | void psignal_sigkill_with_reason(struct proc *p, struct os_reason *signal_reason); |
cb323159 | 257 | #endif /* defined(KERNEL_PRIVATE) */ |
3e170ce0 A |
258 | |
259 | #ifdef XNU_KERNEL_PRIVATE | |
260 | ||
261 | /* Functions exported to Mach as well */ | |
262 | ||
263 | #define COREDUMP_IGNORE_ULIMIT 0x0001 /* Ignore the process's core file ulimit. */ | |
264 | #define COREDUMP_FULLFSYNC 0x0002 /* Run F_FULLFSYNC on the core file's vnode */ | |
265 | ||
0a7de745 | 266 | int coredump(struct proc *p, uint32_t reserve_mb, int coredump_flags); |
39037602 | 267 | void set_thread_exit_reason(void *th, void *reason, boolean_t proc_locked); |
3e170ce0 A |
268 | |
269 | #endif /* XNU_KERNEL_PRIVATE */ | |
270 | ||
271 | ||
0a7de745 | 272 | #endif /* !_SYS_SIGNALVAR_H_ */ |