]>
Commit | Line | Data |
---|---|---|
1c79356b | 1 | /* |
2d21ac55 | 2 | * Copyright (c) 2000-2006 Apple Computer, Inc. All rights reserved. |
5d5c5d0d | 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) 1982, 1986, 1989, 1991, 1993 | |
31 | * The Regents of the University of California. All rights reserved. | |
32 | * (c) UNIX System Laboratories, Inc. | |
33 | * All or some portions of this file are derived from material licensed | |
34 | * to the University of California by American Telephone and Telegraph | |
35 | * Co. or Unix System Laboratories, Inc. and are reproduced herein with | |
36 | * the permission of UNIX System Laboratories, Inc. | |
37 | * | |
38 | * Redistribution and use in source and binary forms, with or without | |
39 | * modification, are permitted provided that the following conditions | |
40 | * are met: | |
41 | * 1. Redistributions of source code must retain the above copyright | |
42 | * notice, this list of conditions and the following disclaimer. | |
43 | * 2. Redistributions in binary form must reproduce the above copyright | |
44 | * notice, this list of conditions and the following disclaimer in the | |
45 | * documentation and/or other materials provided with the distribution. | |
46 | * 3. All advertising materials mentioning features or use of this software | |
47 | * must display the following acknowledgement: | |
48 | * This product includes software developed by the University of | |
49 | * California, Berkeley and its contributors. | |
50 | * 4. Neither the name of the University nor the names of its contributors | |
51 | * may be used to endorse or promote products derived from this software | |
52 | * without specific prior written permission. | |
53 | * | |
54 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | |
55 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
56 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
57 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
58 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
59 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
60 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
61 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
62 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
63 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
64 | * SUCH DAMAGE. | |
65 | * | |
66 | * @(#)signal.h 8.2 (Berkeley) 1/21/94 | |
67 | */ | |
68 | ||
0a7de745 A |
69 | #ifndef _SYS_SIGNAL_H_ |
70 | #define _SYS_SIGNAL_H_ | |
1c79356b | 71 | |
91447636 | 72 | #include <sys/cdefs.h> |
9bccf70c | 73 | #include <sys/appleapiopts.h> |
3e170ce0 | 74 | #include <Availability.h> |
9bccf70c | 75 | |
0a7de745 | 76 | #define __DARWIN_NSIG 32 /* counting 0; could be 33 (mask is 1-32) */ |
2d21ac55 A |
77 | |
78 | #if !defined(_ANSI_SOURCE) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)) | |
0a7de745 | 79 | #define NSIG __DARWIN_NSIG |
1c79356b A |
80 | #endif |
81 | ||
0a7de745 | 82 | #include <machine/signal.h> /* sigcontext; codes for SIGILL, SIGFPE */ |
1c79356b | 83 | |
0a7de745 A |
84 | #define SIGHUP 1 /* hangup */ |
85 | #define SIGINT 2 /* interrupt */ | |
86 | #define SIGQUIT 3 /* quit */ | |
87 | #define SIGILL 4 /* illegal instruction (not reset when caught) */ | |
88 | #define SIGTRAP 5 /* trace trap (not reset when caught) */ | |
89 | #define SIGABRT 6 /* abort() */ | |
2d21ac55 | 90 | #if (defined(_POSIX_C_SOURCE) && !defined(_DARWIN_C_SOURCE)) |
0a7de745 A |
91 | #define SIGPOLL 7 /* pollable event ([XSR] generated, not supported) */ |
92 | #else /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ | |
93 | #define SIGIOT SIGABRT /* compatibility */ | |
94 | #define SIGEMT 7 /* EMT instruction */ | |
95 | #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ | |
96 | #define SIGFPE 8 /* floating point exception */ | |
97 | #define SIGKILL 9 /* kill (cannot be caught or ignored) */ | |
98 | #define SIGBUS 10 /* bus error */ | |
99 | #define SIGSEGV 11 /* segmentation violation */ | |
100 | #define SIGSYS 12 /* bad argument to system call */ | |
101 | #define SIGPIPE 13 /* write on a pipe with no one to read it */ | |
102 | #define SIGALRM 14 /* alarm clock */ | |
103 | #define SIGTERM 15 /* software termination signal from kill */ | |
104 | #define SIGURG 16 /* urgent condition on IO channel */ | |
105 | #define SIGSTOP 17 /* sendable stop signal not from tty */ | |
106 | #define SIGTSTP 18 /* stop signal from tty */ | |
107 | #define SIGCONT 19 /* continue a stopped process */ | |
108 | #define SIGCHLD 20 /* to parent on child stop or exit */ | |
109 | #define SIGTTIN 21 /* to readers pgrp upon background tty read */ | |
110 | #define SIGTTOU 22 /* like TTIN for output if (tp->t_local<OSTOP) */ | |
2d21ac55 | 111 | #if (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)) |
0a7de745 | 112 | #define SIGIO 23 /* input/output possible signal */ |
91447636 | 113 | #endif |
0a7de745 A |
114 | #define SIGXCPU 24 /* exceeded CPU time limit */ |
115 | #define SIGXFSZ 25 /* exceeded file size limit */ | |
116 | #define SIGVTALRM 26 /* virtual time alarm */ | |
117 | #define SIGPROF 27 /* profiling time alarm */ | |
2d21ac55 | 118 | #if (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)) |
0a7de745 A |
119 | #define SIGWINCH 28 /* window size changes */ |
120 | #define SIGINFO 29 /* information request */ | |
1c79356b | 121 | #endif |
0a7de745 A |
122 | #define SIGUSR1 30 /* user defined signal 1 */ |
123 | #define SIGUSR2 31 /* user defined signal 2 */ | |
1c79356b | 124 | |
2d21ac55 | 125 | #if defined(_ANSI_SOURCE) || __DARWIN_UNIX03 || defined(__cplusplus) |
1c79356b A |
126 | /* |
127 | * Language spec sez we must list exactly one parameter, even though we | |
128 | * actually supply three. Ugh! | |
91447636 | 129 | * SIG_HOLD is chosen to avoid KERN_SIG_* values in <sys/signalvar.h> |
1c79356b | 130 | */ |
0a7de745 A |
131 | #define SIG_DFL (void (*)(int))0 |
132 | #define SIG_IGN (void (*)(int))1 | |
133 | #define SIG_HOLD (void (*)(int))5 | |
134 | #define SIG_ERR ((void (*)(int))-1) | |
1c79356b | 135 | #else |
91447636 | 136 | /* DO NOT REMOVE THE COMMENTED OUT int: fixincludes needs to see them */ |
0a7de745 A |
137 | #define SIG_DFL (void (*)( /*int*/ ))0 |
138 | #define SIG_IGN (void (*)( /*int*/ ))1 | |
139 | #define SIG_HOLD (void (*)( /*int*/ ))5 | |
140 | #define SIG_ERR ((void (*)( /*int*/ ))-1) | |
1c79356b A |
141 | #endif |
142 | ||
143 | #ifndef _ANSI_SOURCE | |
91447636 A |
144 | #include <sys/_types.h> |
145 | ||
39236c6e | 146 | #include <machine/_mcontext.h> |
fe8ab488 A |
147 | |
148 | #ifndef KERNEL | |
149 | #include <sys/_pthread/_pthread_attr_t.h> | |
150 | #endif /* KERNEL */ | |
151 | ||
39236c6e A |
152 | #include <sys/_types/_sigaltstack.h> |
153 | #include <sys/_types/_ucontext.h> | |
91447636 | 154 | |
39236c6e | 155 | #include <sys/_types/_pid_t.h> |
39236c6e A |
156 | #include <sys/_types/_sigset_t.h> |
157 | #include <sys/_types/_size_t.h> | |
158 | #include <sys/_types/_uid_t.h> | |
1c79356b | 159 | |
9bccf70c A |
160 | union sigval { |
161 | /* Members as suggested by Annex C of POSIX 1003.1b. */ | |
0a7de745 A |
162 | int sival_int; |
163 | void *sival_ptr; | |
9bccf70c A |
164 | }; |
165 | ||
0a7de745 A |
166 | #define SIGEV_NONE 0 /* No async notification */ |
167 | #define SIGEV_SIGNAL 1 /* aio - completion notification */ | |
168 | #define SIGEV_THREAD 3 /* [NOTIMP] [RTS] call notification function */ | |
9bccf70c | 169 | |
fe8ab488 | 170 | #ifndef KERNEL |
55e303ae | 171 | struct sigevent { |
0a7de745 A |
172 | int sigev_notify; /* Notification type */ |
173 | int sigev_signo; /* Signal number */ | |
174 | union sigval sigev_value; /* Signal value */ | |
175 | void (*sigev_notify_function)(union sigval); /* Notification function */ | |
176 | pthread_attr_t *sigev_notify_attributes; /* Notification attributes */ | |
55e303ae | 177 | }; |
fe8ab488 | 178 | #endif /* KERNEL */ |
55e303ae | 179 | |
91447636 A |
180 | #ifdef BSD_KERNEL_PRIVATE |
181 | ||
b0d623f7 A |
182 | union user64_sigval { |
183 | struct { | |
0a7de745 A |
184 | uint32_t pad; /* assumes Motorola byte order */ |
185 | int32_t sival_int; | |
b0d623f7 | 186 | } size_equivalent; |
0a7de745 | 187 | user64_addr_t sival_ptr; |
b0d623f7 A |
188 | }; |
189 | ||
190 | union user32_sigval { | |
191 | /* Members as suggested by Annex C of POSIX 1003.1b. */ | |
0a7de745 | 192 | int32_t sival_int; |
b0d623f7 A |
193 | user32_addr_t sival_ptr; |
194 | }; | |
195 | ||
91447636 A |
196 | union user_sigval { |
197 | struct { | |
0a7de745 A |
198 | uint32_t pad; /* assumes Motorola byte order */ |
199 | int32_t sival_int; | |
91447636 | 200 | } size_equivalent; |
b0d623f7 A |
201 | user_addr_t sival_ptr; |
202 | }; | |
203 | ||
204 | struct user64_sigevent { | |
0a7de745 A |
205 | int sigev_notify; /* Notification type */ |
206 | int sigev_signo; /* Signal number */ | |
207 | union user64_sigval sigev_value; /* Signal value */ | |
208 | user64_addr_t sigev_notify_function; /* Notify function */ | |
209 | user64_addr_t sigev_notify_attributes; /* Notify attributes */ | |
b0d623f7 A |
210 | }; |
211 | ||
212 | struct user32_sigevent { | |
0a7de745 A |
213 | int sigev_notify; /* Notification type */ |
214 | int sigev_signo; /* Signal number */ | |
215 | union user32_sigval sigev_value; /* Signal value */ | |
216 | user32_addr_t sigev_notify_function; /* Notify function */ | |
217 | user32_addr_t sigev_notify_attributes; /* Notify attributes */ | |
91447636 A |
218 | }; |
219 | ||
220 | struct user_sigevent { | |
0a7de745 A |
221 | int sigev_notify; /* Notification type */ |
222 | int sigev_signo; /* Signal number */ | |
223 | union user_sigval sigev_value; /* Signal value */ | |
224 | user_addr_t sigev_notify_function; /* Notify function */ | |
225 | user_addr_t sigev_notify_attributes; /* Notify attributes */ | |
91447636 A |
226 | }; |
227 | ||
0a7de745 | 228 | #endif /* BSD_KERNEL_PRIVATE */ |
91447636 | 229 | |
9bccf70c | 230 | typedef struct __siginfo { |
0a7de745 A |
231 | int si_signo; /* signal number */ |
232 | int si_errno; /* errno association */ | |
233 | int si_code; /* signal code */ | |
234 | pid_t si_pid; /* sending process */ | |
235 | uid_t si_uid; /* sender's ruid */ | |
236 | int si_status; /* exit value */ | |
237 | void *si_addr; /* faulting instruction */ | |
238 | union sigval si_value; /* signal value */ | |
239 | long si_band; /* band event for SIGPOLL */ | |
240 | unsigned long __pad[7]; /* Reserved for Future Use */ | |
9bccf70c A |
241 | } siginfo_t; |
242 | ||
91447636 A |
243 | #ifdef BSD_KERNEL_PRIVATE |
244 | ||
b0d623f7 | 245 | typedef struct user_siginfo { |
0a7de745 A |
246 | int si_signo; /* signal number */ |
247 | int si_errno; /* errno association */ | |
248 | int si_code; /* signal code */ | |
249 | pid_t si_pid; /* sending process */ | |
250 | uid_t si_uid; /* sender's ruid */ | |
251 | int si_status; /* exit value */ | |
252 | user_addr_t si_addr; /* faulting instruction (see below) */ | |
253 | union user_sigval si_value; /* signal value */ | |
254 | user_long_t si_band; /* band event for SIGPOLL */ | |
255 | user_ulong_t pad[7]; /* Reserved for Future Use */ | |
91447636 A |
256 | } user_siginfo_t; |
257 | ||
b0d623f7 | 258 | typedef struct user64_siginfo { |
0a7de745 A |
259 | int si_signo; /* signal number */ |
260 | int si_errno; /* errno association */ | |
261 | int si_code; /* signal code */ | |
262 | pid_t si_pid; /* sending process */ | |
263 | uid_t si_uid; /* sender's ruid */ | |
264 | int si_status; /* exit value */ | |
265 | user64_addr_t si_addr; /* faulting instruction (see below) */ | |
266 | union user64_sigval si_value; /* signal value */ | |
267 | user64_long_t si_band; /* band event for SIGPOLL */ | |
268 | user64_ulong_t __pad[7]; /* Reserved for Future Use */ | |
b0d623f7 A |
269 | } user64_siginfo_t; |
270 | ||
271 | typedef struct user32_siginfo { | |
0a7de745 A |
272 | int si_signo; /* signal number */ |
273 | int si_errno; /* errno association */ | |
274 | int si_code; /* signal code */ | |
275 | pid_t si_pid; /* sending process */ | |
276 | uid_t si_uid; /* sender's ruid */ | |
277 | int si_status; /* exit value */ | |
278 | user32_addr_t si_addr; /* faulting instruction (see below) */ | |
279 | union user32_sigval si_value; /* signal value */ | |
280 | user32_long_t si_band; /* band event for SIGPOLL */ | |
281 | user32_ulong_t __pad[7]; /* Reserved for Future Use */ | |
b0d623f7 A |
282 | } user32_siginfo_t; |
283 | ||
316670eb A |
284 | void siginfo_user_to_user32(user_siginfo_t *, user32_siginfo_t *); |
285 | void siginfo_user_to_user64(user_siginfo_t *, user64_siginfo_t *); | |
286 | ||
0a7de745 | 287 | #endif /* BSD_KERNEL_PRIVATE */ |
91447636 | 288 | |
0a7de745 A |
289 | /* |
290 | * When the signal is SIGILL or SIGFPE, si_addr contains the address of | |
2d21ac55 | 291 | * the faulting instruction. |
0a7de745 | 292 | * When the signal is SIGSEGV or SIGBUS, si_addr contains the address of |
2d21ac55 | 293 | * the faulting memory reference. Although for x86 there are cases of SIGSEGV |
0a7de745 | 294 | * for which si_addr cannot be determined and is NULL. |
2d21ac55 A |
295 | * If the signal is SIGCHLD, the si_pid field will contain the child process ID, |
296 | * si_status contains the exit value or signal and | |
297 | * si_uid contains the real user ID of the process that sent the signal. | |
9bccf70c A |
298 | */ |
299 | ||
300 | /* Values for si_code */ | |
301 | ||
302 | /* Codes for SIGILL */ | |
2d21ac55 | 303 | #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) |
0a7de745 | 304 | #define ILL_NOOP 0 /* if only I knew... */ |
91447636 | 305 | #endif |
0a7de745 A |
306 | #define ILL_ILLOPC 1 /* [XSI] illegal opcode */ |
307 | #define ILL_ILLTRP 2 /* [XSI] illegal trap */ | |
308 | #define ILL_PRVOPC 3 /* [XSI] privileged opcode */ | |
309 | #define ILL_ILLOPN 4 /* [XSI] illegal operand -NOTIMP */ | |
310 | #define ILL_ILLADR 5 /* [XSI] illegal addressing mode -NOTIMP */ | |
311 | #define ILL_PRVREG 6 /* [XSI] privileged register -NOTIMP */ | |
312 | #define ILL_COPROC 7 /* [XSI] coprocessor error -NOTIMP */ | |
313 | #define ILL_BADSTK 8 /* [XSI] internal stack error -NOTIMP */ | |
9bccf70c A |
314 | |
315 | /* Codes for SIGFPE */ | |
2d21ac55 | 316 | #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) |
0a7de745 | 317 | #define FPE_NOOP 0 /* if only I knew... */ |
91447636 | 318 | #endif |
0a7de745 A |
319 | #define FPE_FLTDIV 1 /* [XSI] floating point divide by zero */ |
320 | #define FPE_FLTOVF 2 /* [XSI] floating point overflow */ | |
321 | #define FPE_FLTUND 3 /* [XSI] floating point underflow */ | |
322 | #define FPE_FLTRES 4 /* [XSI] floating point inexact result */ | |
323 | #define FPE_FLTINV 5 /* [XSI] invalid floating point operation */ | |
324 | #define FPE_FLTSUB 6 /* [XSI] subscript out of range -NOTIMP */ | |
325 | #define FPE_INTDIV 7 /* [XSI] integer divide by zero */ | |
326 | #define FPE_INTOVF 8 /* [XSI] integer overflow */ | |
9bccf70c A |
327 | |
328 | /* Codes for SIGSEGV */ | |
2d21ac55 | 329 | #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) |
0a7de745 | 330 | #define SEGV_NOOP 0 /* if only I knew... */ |
91447636 | 331 | #endif |
0a7de745 A |
332 | #define SEGV_MAPERR 1 /* [XSI] address not mapped to object */ |
333 | #define SEGV_ACCERR 2 /* [XSI] invalid permission for mapped object */ | |
9bccf70c A |
334 | |
335 | /* Codes for SIGBUS */ | |
2d21ac55 | 336 | #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) |
0a7de745 | 337 | #define BUS_NOOP 0 /* if only I knew... */ |
91447636 | 338 | #endif |
0a7de745 A |
339 | #define BUS_ADRALN 1 /* [XSI] Invalid address alignment */ |
340 | #define BUS_ADRERR 2 /* [XSI] Nonexistent physical address -NOTIMP */ | |
341 | #define BUS_OBJERR 3 /* [XSI] Object-specific HW error - NOTIMP */ | |
91447636 A |
342 | |
343 | /* Codes for SIGTRAP */ | |
0a7de745 A |
344 | #define TRAP_BRKPT 1 /* [XSI] Process breakpoint -NOTIMP */ |
345 | #define TRAP_TRACE 2 /* [XSI] Process trace trap -NOTIMP */ | |
9bccf70c A |
346 | |
347 | /* Codes for SIGCHLD */ | |
2d21ac55 | 348 | #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) |
0a7de745 | 349 | #define CLD_NOOP 0 /* if only I knew... */ |
91447636 | 350 | #endif |
0a7de745 A |
351 | #define CLD_EXITED 1 /* [XSI] child has exited */ |
352 | #define CLD_KILLED 2 /* [XSI] terminated abnormally, no core file */ | |
353 | #define CLD_DUMPED 3 /* [XSI] terminated abnormally, core file */ | |
354 | #define CLD_TRAPPED 4 /* [XSI] traced child has trapped */ | |
355 | #define CLD_STOPPED 5 /* [XSI] child has stopped */ | |
356 | #define CLD_CONTINUED 6 /* [XSI] stopped child has continued */ | |
91447636 A |
357 | |
358 | /* Codes for SIGPOLL */ | |
0a7de745 A |
359 | #define POLL_IN 1 /* [XSR] Data input available */ |
360 | #define POLL_OUT 2 /* [XSR] Output buffers available */ | |
361 | #define POLL_MSG 3 /* [XSR] Input message available */ | |
362 | #define POLL_ERR 4 /* [XSR] I/O error */ | |
363 | #define POLL_PRI 5 /* [XSR] High priority input available */ | |
364 | #define POLL_HUP 6 /* [XSR] Device disconnected */ | |
9bccf70c A |
365 | |
366 | /* union for signal handlers */ | |
367 | union __sigaction_u { | |
368 | void (*__sa_handler)(int); | |
369 | void (*__sa_sigaction)(int, struct __siginfo *, | |
0a7de745 | 370 | void *); |
9bccf70c A |
371 | }; |
372 | ||
373 | /* Signal vector template for Kernel user boundary */ | |
0a7de745 | 374 | struct __sigaction { |
9bccf70c A |
375 | union __sigaction_u __sigaction_u; /* signal handler */ |
376 | void (*sa_tramp)(void *, int, int, siginfo_t *, void *); | |
0a7de745 A |
377 | sigset_t sa_mask; /* signal mask to apply */ |
378 | int sa_flags; /* see signal options below */ | |
9bccf70c A |
379 | }; |
380 | ||
1c79356b A |
381 | /* |
382 | * Signal vector "template" used in sigaction call. | |
383 | */ | |
0a7de745 | 384 | struct sigaction { |
9bccf70c | 385 | union __sigaction_u __sigaction_u; /* signal handler */ |
0a7de745 A |
386 | sigset_t sa_mask; /* signal mask to apply */ |
387 | int sa_flags; /* see signal options below */ | |
1c79356b | 388 | }; |
91447636 | 389 | |
0a7de745 | 390 | #ifdef BSD_KERNEL_PRIVATE |
91447636 A |
391 | #include <machine/types.h> |
392 | ||
b0d623f7 A |
393 | union __user32_sigaction_u { |
394 | user32_addr_t __sa_handler; | |
395 | user32_addr_t __sa_sigaction; | |
396 | }; | |
397 | ||
0a7de745 | 398 | struct user32_sigaction { |
b0d623f7 | 399 | union __user32_sigaction_u __sigaction_u; /* signal handler */ |
0a7de745 A |
400 | sigset_t sa_mask; /* signal mask to apply */ |
401 | int sa_flags; /* see signal options below */ | |
b0d623f7 A |
402 | }; |
403 | ||
0a7de745 | 404 | struct __user32_sigaction { |
b0d623f7 A |
405 | union __user32_sigaction_u __sigaction_u; /* signal handler */ |
406 | user32_addr_t sa_tramp; | |
0a7de745 A |
407 | sigset_t sa_mask; /* signal mask to apply */ |
408 | int sa_flags; /* see signal options below */ | |
b0d623f7 A |
409 | }; |
410 | ||
411 | union __user64_sigaction_u { | |
0a7de745 A |
412 | user64_addr_t __sa_handler; |
413 | user64_addr_t __sa_sigaction; | |
b0d623f7 A |
414 | }; |
415 | ||
0a7de745 | 416 | struct user64_sigaction { |
b0d623f7 | 417 | union __user64_sigaction_u __sigaction_u; /* signal handler */ |
0a7de745 A |
418 | sigset_t sa_mask; /* signal mask to apply */ |
419 | int sa_flags; /* see signal options below */ | |
b0d623f7 A |
420 | }; |
421 | ||
0a7de745 | 422 | struct __user64_sigaction { |
b0d623f7 | 423 | union __user64_sigaction_u __sigaction_u; /* signal handler */ |
0a7de745 A |
424 | user64_addr_t sa_tramp; /* signal mask to apply */ |
425 | sigset_t sa_mask; /* signal mask to apply */ | |
426 | int sa_flags; /* see signal options below */ | |
b0d623f7 A |
427 | }; |
428 | ||
429 | union __kern_sigaction_u { | |
0a7de745 A |
430 | user_addr_t __sa_handler; |
431 | user_addr_t __sa_sigaction; | |
91447636 A |
432 | }; |
433 | ||
0a7de745 | 434 | struct kern_sigaction { |
b0d623f7 | 435 | union __kern_sigaction_u __sigaction_u; /* signal handler */ |
0a7de745 A |
436 | sigset_t sa_mask; /* signal mask to apply */ |
437 | int sa_flags; /* see signal options below */ | |
91447636 A |
438 | }; |
439 | ||
0a7de745 | 440 | struct __kern_sigaction { |
b0d623f7 | 441 | union __kern_sigaction_u __sigaction_u; /* signal handler */ |
0a7de745 A |
442 | user_addr_t sa_tramp; /* signal mask to apply */ |
443 | sigset_t sa_mask; /* signal mask to apply */ | |
444 | int sa_flags; /* see signal options below */ | |
91447636 A |
445 | }; |
446 | ||
91447636 A |
447 | #undef SIG_DFL |
448 | #undef SIG_IGN | |
449 | #undef SIG_ERR | |
0a7de745 A |
450 | #define SIG_DFL ((user_addr_t)0LL) |
451 | #define SIG_IGN ((user_addr_t)1LL) | |
452 | #define SIG_ERR ((user_addr_t)-1LL) | |
91447636 | 453 | |
0a7de745 | 454 | #endif /* BSD_KERNEL_PRIVATE */ |
91447636 A |
455 | |
456 | ||
9bccf70c | 457 | /* if SA_SIGINFO is set, sa_sigaction is to be used instead of sa_handler. */ |
0a7de745 A |
458 | #define sa_handler __sigaction_u.__sa_handler |
459 | #define sa_sigaction __sigaction_u.__sa_sigaction | |
460 | ||
461 | #define SA_ONSTACK 0x0001 /* take signal on signal stack */ | |
462 | #define SA_RESTART 0x0002 /* restart system on signal return */ | |
463 | #ifdef BSD_KERNEL_PRIVATE | |
464 | #define SA_DISABLE 0x0004 /* disable taking signals on alternate stack - for user_sigaltstack.ss_flags only */ | |
465 | #endif /* BSD_KERNEL_PRIVATE */ | |
466 | #define SA_RESETHAND 0x0004 /* reset to SIG_DFL when taking signal */ | |
467 | #define SA_NOCLDSTOP 0x0008 /* do not generate SIGCHLD on child stop */ | |
468 | #define SA_NODEFER 0x0010 /* don't mask the signal we're delivering */ | |
469 | #define SA_NOCLDWAIT 0x0020 /* don't keep zombies around */ | |
470 | #define SA_SIGINFO 0x0040 /* signal handler with SA_SIGINFO args */ | |
2d21ac55 | 471 | #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) |
0a7de745 | 472 | #define SA_USERTRAMP 0x0100 /* do not bounce off kernel's sigtramp */ |
55e303ae | 473 | /* This will provide 64bit register set in a 32bit user address space */ |
0a7de745 | 474 | #define SA_64REGSET 0x0200 /* signal handler with SA_SIGINFO args with 64bit regs information */ |
2d21ac55 | 475 | #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ |
0a7de745 A |
476 | #ifdef BSD_KERNEL_PRIVATE |
477 | #define SA_VALIDATE_SIGRETURN_FROM_SIGTRAMP 0x0400 /* use token to validate sigreturn was called from matching sigtramp */ | |
478 | #endif /* BSD_KERNEL_PRIVATE */ | |
2d21ac55 | 479 | |
0a7de745 | 480 | /* the following are the only bits we support from user space, the |
2d21ac55 A |
481 | * rest are for kernel use only. |
482 | */ | |
483 | #define SA_USERSPACE_MASK (SA_ONSTACK | SA_RESTART | SA_RESETHAND | SA_NOCLDSTOP | SA_NODEFER | SA_NOCLDWAIT | SA_SIGINFO) | |
1c79356b A |
484 | |
485 | /* | |
486 | * Flags for sigprocmask: | |
487 | */ | |
0a7de745 A |
488 | #define SIG_BLOCK 1 /* block specified signal set */ |
489 | #define SIG_UNBLOCK 2 /* unblock specified signal set */ | |
490 | #define SIG_SETMASK 3 /* set specified signal set */ | |
1c79356b | 491 | |
9bccf70c | 492 | /* POSIX 1003.1b required values. */ |
0a7de745 A |
493 | #define SI_USER 0x10001 /* [CX] signal from kill() */ |
494 | #define SI_QUEUE 0x10002 /* [CX] signal from sigqueue() */ | |
495 | #define SI_TIMER 0x10003 /* [CX] timer expiration */ | |
496 | #define SI_ASYNCIO 0x10004 /* [CX] aio request completion */ | |
497 | #define SI_MESGQ 0x10005 /* [CX] from message arrival on empty queue */ | |
91447636 | 498 | |
2d21ac55 | 499 | #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) |
0a7de745 | 500 | typedef void (*sig_t)(int); /* type of signal function */ |
91447636 | 501 | #endif |
1c79356b A |
502 | |
503 | /* | |
504 | * Structure used in sigaltstack call. | |
505 | */ | |
0a7de745 | 506 | #ifdef BSD_KERNEL_PRIVATE |
91447636 | 507 | |
b0d623f7 | 508 | struct user32_sigaltstack { |
0a7de745 A |
509 | user32_addr_t ss_sp; /* signal stack base */ |
510 | user32_size_t ss_size; /* signal stack length */ | |
511 | int ss_flags; /* SA_DISABLE and/or SA_ONSTACK */ | |
b0d623f7 A |
512 | }; |
513 | ||
514 | struct user64_sigaltstack { | |
0a7de745 A |
515 | user64_addr_t ss_sp; /* signal stack base */ |
516 | user64_size_t ss_size; /* signal stack length */ | |
517 | int ss_flags; /* SA_DISABLE and/or SA_ONSTACK */ | |
b0d623f7 A |
518 | }; |
519 | ||
520 | struct kern_sigaltstack { | |
0a7de745 A |
521 | user_addr_t ss_sp; /* signal stack base */ |
522 | user_size_t ss_size; /* signal stack length */ | |
523 | int ss_flags; /* SA_DISABLE and/or SA_ONSTACK */ | |
1c79356b | 524 | }; |
9bccf70c | 525 | |
0a7de745 | 526 | #endif /* BSD_KERNEL_PRIVATE */ |
91447636 | 527 | |
0a7de745 A |
528 | #define SS_ONSTACK 0x0001 /* take signal on signal stack */ |
529 | #define SS_DISABLE 0x0004 /* disable taking signals on alternate stack */ | |
530 | #define MINSIGSTKSZ 32768 /* (32K)minimum allowable stack */ | |
531 | #define SIGSTKSZ 131072 /* (128K)recommended stack size */ | |
1c79356b | 532 | |
2d21ac55 | 533 | #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) |
1c79356b A |
534 | /* |
535 | * 4.3 compatibility: | |
536 | * Signal vector "template" used in sigvec call. | |
537 | */ | |
0a7de745 A |
538 | struct sigvec { |
539 | void (*sv_handler)(int); /* signal handler */ | |
540 | int sv_mask; /* signal mask to apply */ | |
541 | int sv_flags; /* see signal options below */ | |
1c79356b A |
542 | }; |
543 | ||
0a7de745 A |
544 | #define SV_ONSTACK SA_ONSTACK |
545 | #define SV_INTERRUPT SA_RESTART /* same bit, opposite sense */ | |
546 | #define SV_RESETHAND SA_RESETHAND | |
547 | #define SV_NODEFER SA_NODEFER | |
548 | #define SV_NOCLDSTOP SA_NOCLDSTOP | |
549 | #define SV_SIGINFO SA_SIGINFO | |
9bccf70c | 550 | |
0a7de745 | 551 | #define sv_onstack sv_flags /* isn't compatibility wonderful! */ |
2d21ac55 | 552 | #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ |
1c79356b A |
553 | |
554 | /* | |
555 | * Structure used in sigstack call. | |
556 | */ | |
0a7de745 A |
557 | struct sigstack { |
558 | char *ss_sp; /* signal stack pointer */ | |
559 | int ss_onstack; /* current status */ | |
1c79356b A |
560 | }; |
561 | ||
2d21ac55 | 562 | #if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE) |
1c79356b A |
563 | /* |
564 | * Macro for converting signal number to a mask suitable for | |
565 | * sigblock(). | |
566 | */ | |
0a7de745 | 567 | #define sigmask(m) (1 << ((m)-1)) |
1c79356b | 568 | |
0a7de745 | 569 | #ifdef KERNEL_PRIVATE |
9bccf70c A |
570 | /* |
571 | * signals delivered on a per-thread basis. | |
572 | */ | |
573 | #define threadmask (sigmask(SIGILL)|sigmask(SIGTRAP)|\ | |
0a7de745 A |
574 | sigmask(SIGABRT)|sigmask(SIGEMT)|\ |
575 | sigmask(SIGFPE)|sigmask(SIGBUS)|\ | |
576 | sigmask(SIGSEGV)|sigmask(SIGSYS)|\ | |
577 | sigmask(SIGPIPE)|sigmask(SIGKILL)) | |
b0d623f7 | 578 | |
5ba3f43e | 579 | #define workq_threadmask ((threadmask | sigcantmask | sigmask(SIGPROF)) & ~sigmask(SIGABRT)) |
b0d623f7 A |
580 | |
581 | /* | |
582 | * Signals carried across exec. | |
583 | */ | |
584 | #define execmask (sigmask(SIGHUP)|sigmask(SIGINT)|\ | |
0a7de745 A |
585 | sigmask(SIGQUIT)|sigmask(SIGKILL)|\ |
586 | sigmask(SIGTERM)|sigmask(SIGSTOP)|\ | |
587 | sigmask(SIGTSTP)|sigmask(SIGCONT)|\ | |
588 | sigmask(SIGTTIN)|sigmask(SIGTTOU)|\ | |
589 | sigmask(SIGUSR1)|sigmask(SIGUSR2)) | |
b0d623f7 | 590 | |
0a7de745 | 591 | #endif /* KERNEL_PRIVATE */ |
1c79356b | 592 | |
0a7de745 | 593 | #define BADSIG SIG_ERR |
1c79356b | 594 | |
0a7de745 A |
595 | #endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */ |
596 | #endif /* !_ANSI_SOURCE */ | |
1c79356b A |
597 | |
598 | /* | |
599 | * For historical reasons; programs expect signal's return value to be | |
600 | * defined by <sys/signal.h>. | |
601 | */ | |
602 | __BEGIN_DECLS | |
0a7de745 | 603 | void(*signal(int, void (*)(int)))(int); |
1c79356b | 604 | __END_DECLS |
0a7de745 | 605 | #endif /* !_SYS_SIGNAL_H_ */ |