fxr.watson.org: sys/sys/signal.h (original) (raw)
FreeBSD/Linux Kernel Cross Reference
[1](source/sys/signal.h#L1) **_/*-_**
[2](source/sys/signal.h#L2) **_* SPDX-License-Identifier: BSD-3-Clause_**
[3](source/sys/signal.h#L3) **_*_**
[4](source/sys/signal.h#L4) **_* Copyright (c) 1982, 1986, 1989, 1991, 1993_**
[5](source/sys/signal.h#L5) **_* The Regents of the University of California. All rights reserved._**
[6](source/sys/signal.h#L6) **_* (c) UNIX System Laboratories, Inc._**
[7](source/sys/signal.h#L7) **_* All or some portions of this file are derived from material licensed_**
[8](source/sys/signal.h#L8) **_* to the University of California by American Telephone and Telegraph_**
[9](source/sys/signal.h#L9) **_* Co. or Unix System Laboratories, Inc. and are reproduced herein with_**
10 _ the permission of UNIX System Laboratories, Inc._*
11 *
12 _ Redistribution and use in source and binary forms, with or without_*
13 _ modification, are permitted provided that the following conditions_*
14 _ are met:_*
15 _ 1. Redistributions of source code must retain the above copyright_*
16 _ notice, this list of conditions and the following disclaimer._*
17 _ 2. Redistributions in binary form must reproduce the above copyright_*
18 _ notice, this list of conditions and the following disclaimer in the_*
19 _ documentation and/or other materials provided with the distribution._*
20 _ 3. Neither the name of the University nor the names of its contributors_*
21 _ may be used to endorse or promote products derived from this software_*
22 _ without specific prior written permission._*
23 *
24 _ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND_*
25 _ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE_*
26 _ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE_*
27 _ ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE_*
28 _ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL_*
29 _ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS_*
30 _ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)_*
31 _ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT_*
32 _ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY_*
33 _ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF_*
34 _ SUCH DAMAGE._*
35 *
36 _ @(#)signal.h 8.4 (Berkeley) 5/4/95_*
37 _ FreeBSDFreeBSDFreeBSD_*
38 */
39
40 #ifndef SYS_SIGNAL_H
41 #define SYS_SIGNAL_H
42
43 #include <sys/cdefs.h>
44 #include <sys/types.h>
45 #include <sys/_sigset.h>
46
47 #include <machine/_limits.h> /* _MINSIGSTKSZ /
48 #include <machine/signal.h> / sig_atomic_t; trap codes; sigcontext */
49
50 #if __POSIX_VISIBLE >= 200809
51
52 #include <sys/_pthreadtypes.h>
53 #include <sys/_timespec.h>
54
55 #ifndef _SIZE_T_DECLARED
56 typedef __size_t size_t;
57 #define _SIZE_T_DECLARED
58 #endif
59
60 #ifndef _UID_T_DECLARED
61 typedef __uid_t uid_t;
62 #define _UID_T_DECLARED
63 #endif
64
65 #endif **/* POSIXVISIBLE >= 200809 */**
66
67 **_/***
68 _ System defined signals._*
69 */
70 #if __POSIX_VISIBLE || __XSI_VISIBLE
71 #define SIGHUP 1 /* hangup */
72 #endif
73 #define SIGINT 2 /* interrupt */
74 #if __POSIX_VISIBLE || __XSI_VISIBLE
75 #define SIGQUIT 3 /* quit */
76 #endif
77 #define SIGILL 4 /* illegal instr. (not reset when caught) */
78 #if __XSI_VISIBLE
79 #define SIGTRAP 5 /* trace trap (not reset when caught) */
80 #endif
81 #define SIGABRT 6 /* abort() */
82 #if __BSD_VISIBLE
83 #define SIGIOT SIGABRT /* compatibility */
84 #define SIGEMT 7 /* EMT instruction */
85 #endif
86 #define SIGFPE 8 /* floating point exception */
87 #if __POSIX_VISIBLE || __XSI_VISIBLE
88 #define SIGKILL 9 /* kill (cannot be caught or ignored) */
89 #endif
90 #if __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE
91 #define SIGBUS 10 /* bus error */
92 #endif
93 #define SIGSEGV 11 /* segmentation violation */
94 #if __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE
95 #define SIGSYS 12 /* non-existent system call invoked */
96 #endif
97 #if __POSIX_VISIBLE || __XSI_VISIBLE
98 #define SIGPIPE 13 /* write on a pipe with no one to read it */
99 #define SIGALRM 14 /* alarm clock */
100 #endif
101 #define SIGTERM 15 /* software termination signal from kill */
102 #if __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE
103 #define SIGURG 16 /* urgent condition on IO channel */
104 #endif
105 #if __POSIX_VISIBLE || __XSI_VISIBLE
106 #define SIGSTOP 17 /* sendable stop signal not from tty */
107 #define SIGTSTP 18 /* stop signal from tty */
108 #define SIGCONT 19 /* continue a stopped process */
109 #define SIGCHLD 20 /* to parent on child stop or exit */
110 #define SIGTTIN 21 /* to readers pgrp upon background tty read */
111 #define SIGTTOU 22 /* like TTIN if (tp->tlocal<OSTOP) */
112 #endif
113 #if __BSD_VISIBLE
114 #define SIGIO 23 /* input/output possible signal */
115 #endif
116 #if __XSI_VISIBLE
117 #define SIGXCPU 24 /* exceeded CPU time limit */
118 #define SIGXFSZ 25 /* exceeded file size limit */
119 #define SIGVTALRM 26 /* virtual time alarm */
120 #define SIGPROF 27 /* profiling time alarm */
121 #endif
122 #if __BSD_VISIBLE
123 #define SIGWINCH 28 /* window size changes */
124 #define SIGINFO 29 /* information request */
125 #endif
126 #if __POSIX_VISIBLE || __XSI_VISIBLE
127 #define SIGUSR1 30 /* user defined signal 1 */
128 #define SIGUSR2 31 /* user defined signal 2 */
129 #endif
130 #if __BSD_VISIBLE
131 #define SIGTHR 32 /* reserved by thread library. */
132 #define SIGLWP SIGTHR
133 #define SIGLIBRT 33 /* reserved by real-time library. */
134 #endif
135
136 #define SIGRTMIN 65
137 #define SIGRTMAX 126
138
139 #define SIG_DFL ((__sighandler_t )0)
140 #define SIG_IGN ((__sighandler_t )1)
141 #define SIG_ERR ((__sighandler_t )-1)
142 **_/* #define SIGCATCH ((sighandlert *)2) See signalvar.h */**
143 #define SIG_HOLD ((__sighandler_t )3)
144
145 **_/_
146 _ Type of a signal handling function._*
147 **_*_*
148 _ Language spec sez signal handlers take exactly one arg, even though we_
149 _ actually supply three. Ugh!_
150 *
151 _ We don't try to hide the difference by leaving out the args because_*
152 _ that would cause warnings about conformant programs. Nonconformant_*
153 _* programs can avoid the warnings by casting to (sighandlert *) or
154 _ sigt before calling signal() or assigning to sahandler or svhandler._*
155 *
156 _ The kernel should reverse the cast before calling the function. It_*
157 _ has no way to do this, but on most machines 1-arg and 3-arg functions_*
158 _ have the same calling protocol so there is no problem in practice._*
159 _ A bit in saflags could be used to specify the number of args._*
160 */
161 typedef void __sighandler_t(int);
162
163 #if __POSIX_VISIBLE || __XSI_VISIBLE
164 #ifndef _SIGSET_T_DECLARED
165 #define _SIGSET_T_DECLARED
166 typedef __sigset_t sigset_t;
167 #endif
168 #endif
169
170 #if __POSIX_VISIBLE >= 199309 || __XSI_VISIBLE >= 500
171 union sigval {
172 /* Members as suggested by Annex C of POSIX 1003.1b. */
173 int sival_int;
174 void sival_ptr;
175 /* 6.0 compatibility */
176 int sigval_int;
177 void sigval_ptr;
178 };
179
180 #if defined(WANT_LWPINFO32) || (defined(_KERNEL) && defined(LP64))
181 union sigval32 {
182 int sival_int;
183 uint32_t sival_ptr;
184 **/* 6.0 compatibility /_*
185 int sigval_int;
186 uint32_t sigval_ptr;
187 };
188 #endif
189 #endif
190
191 #if __POSIX_VISIBLE >= 199309
192
193 struct pthread_attr;
194
195 struct sigevent {
196 int sigev_notify; /* Notification type */
197 int sigev_signo; /* Signal number */
198 union sigval sigev_value; /* Signal value */
199 union {
200 __lwpid_t _threadid;
201 struct {
202 void (function)(union sigval);
203 struct pthread_attr **attribute;
204 } sigev_thread;
205 unsigned short kevent_flags;
206 long spare[8];
207 } sigev_un;
208 };
209
210 #if __BSD_VISIBLE
211 #define sigev_notify_kqueue sigev_signo
212 #define sigev_notify_kevent_flags sigev_un.kevent_flags
213 #define sigev_notify_thread_id sigev_un.threadid
214 #endif
215 #define sigev_notify_function sigev_un.sigev_thread.function
216 #define sigev_notify_attributes sigev_un.sigev_thread.attribute
217
218 #define SIGEV_NONE 0 **/* No async notification. */**
219 #define SIGEV_SIGNAL 1 **/* Generate a queued signal. */**
220 #define SIGEV_THREAD 2 **/* Call back from another pthread. */**
221 #if __BSD_VISIBLE
222 #define SIGEV_KEVENT 3 **/* Generate a kevent. */**
223 #define SIGEV_THREAD_ID 4 **/* Send signal to a kernel thread. */**
224 #endif
225
226 #endif **/* POSIXVISIBLE >= 199309 */**
227
228 #if __POSIX_VISIBLE >= 199309 || __XSI_VISIBLE
229 typedef struct __siginfo {
230 int si_signo; **/* signal number */**
231 int si_errno; **/* errno association */**
232 /*
233 _ Cause of signal, one of the SI macros or signal-specific_*
234 _ values, i.e. one of the FPE... values for SIGFPE. This_
235 _ value is equivalent to the second argument to an old-style_*
236 _ FreeBSD signal handler._*
237 */
238 int si_code; /* signal code */
239 __pid_t si_pid; /* sending process */
240 __uid_t si_uid; /* sender's ruid */
241 int si_status; /* exit value */
242 void si_addr; /* faulting instruction */
243 union sigval si_value; /* signal value */
244 union {
245 struct {
246 int trapno;**/ machine specific trap code /_*
247 } fault;
248 struct {
249 int timerid;
250 int overrun;
251 } timer;
252 struct {
253 int mqd;
254 } mesgq;
255 struct {
256 long band; **/* band event for SIGPOLL */**
257 } poll; **/* was this ever used ? */**
258 struct {
259 int syscall; **/* Syscall number for signals**
260 *** delivered as a result of**
261 *** system calls denied by_**
262 * Capsicum. */
263 } capsicum;
264 struct {
265 long spare1;
266 int spare2[7];
267 } spare;
268 } reason;
269 } siginfo_t;
270
271 #define si_trapno reason.fault.trapno
272 #define si_timerid reason.timer.timerid
273 #define si_overrun reason.timer.overrun
274 #define si_mqd reason.mesgq.mqd
275 #define si_band reason.poll.band
276 #define si_syscall reason.capsicum.syscall
277
278 #if defined(WANT_LWPINFO32) || (defined(_KERNEL) && defined(LP64))
279 struct siginfo32 {
280 int si_signo; **/* signal number */**
281 int si_errno; **/* errno association */**
282 int si_code; **/* signal code */**
283 __pid_t si_pid; **/* sending process */**
284 __uid_t si_uid; **/* sender's ruid */**
285 int si_status; **/* exit value */**
286 uint32_t si_addr; **/* faulting instruction */**
287 union sigval32 si_value; **/* signal value */**
288 union {
289 struct {
290 int trapno;**/* machine specific trap code */**
291 } fault;
292 struct {
293 int timerid;
294 int overrun;
295 } timer;
296 struct {
297 int mqd;
298 } mesgq;
299 struct {
300 int32_t band; **/* band event for SIGPOLL */**
301 } poll; **/* was this ever used ? */**
302 struct {
303 int32_t spare1;
304 int spare2[7];
305 } spare;
306 } reason;
307 };
308 #endif
309
310 **/ sicode /**
311 **/* codes for SIGILL */**
312 #define ILL_ILLOPC 1 **/* Illegal opcode. */**
313 #define ILL_ILLOPN 2 **/* Illegal operand. */**
314 #define ILL_ILLADR 3 **/* Illegal addressing mode. /_*
315 #define ILL_ILLTRP 4 /* Illegal trap. */
316 #define ILL_PRVOPC 5 /* Privileged opcode. */
317 #define ILL_PRVREG 6 /* Privileged register. */
318 #define ILL_COPROC 7 /* Coprocessor error. */
319 #define ILL_BADSTK 8 /* Internal stack error. */
320
321 /* codes for SIGBUS */
322 #define BUS_ADRALN 1 /* Invalid address alignment. */
323 #define BUS_ADRERR 2 /* Nonexistent physical address. */
324 #define BUS_OBJERR 3 /* Object-specific hardware error. */
325 #define BUS_OOMERR 100 /* Non-standard: No memory. */
326
327 /* codes for SIGSEGV */
328 #define SEGV_MAPERR 1 /* Address not mapped to object. */
329 #define SEGV_ACCERR 2 /* Invalid permissions for mapped */
330 /* object. */
331 #define SEGV_PKUERR 100 /* x86: PKU violation */
332
333 /* codes for SIGFPE */
334 #define FPE_INTOVF 1 /* Integer overflow. */
335 #define FPE_INTDIV 2 /* Integer divide by zero. */
336 #define FPE_FLTDIV 3 /* Floating point divide by zero. */
337 #define FPE_FLTOVF 4 /* Floating point overflow. */
338 #define FPE_FLTUND 5 /* Floating point underflow. */
339 #define FPE_FLTRES 6 /* Floating point inexact result. */
340 #define FPE_FLTINV 7 /* Invalid floating point operation. */
341 #define FPE_FLTSUB 8 /* Subscript out of range. */
342 #define FPE_FLTIDO 9 /* Input denormal operation */
343
344 /* codes for SIGTRAP */
345 #define TRAP_BRKPT 1 /* Process breakpoint. */
346 #define TRAP_TRACE 2 /* Process trace trap. */
347 #define TRAP_DTRACE 3 /* DTrace induced trap. */
348 #define TRAP_CAP 4 /* Capabilities protective trap. */
349
350 /* codes for SIGCHLD */
351 #define CLD_EXITED 1 /* Child has exited */
352 #define CLD_KILLED 2 /* Child has terminated abnormally but */
353 /* did not create a core file */
354 #define CLD_DUMPED 3 /* Child has terminated abnormally and */
355 /* created a core file */
356 #define CLD_TRAPPED 4 /* Traced child has trapped */
357 #define CLD_STOPPED 5 /* Child has stopped */
358 #define CLD_CONTINUED 6 /* Stopped child has continued */
359
360 /* codes for SIGPOLL */
361 #define POLL_IN 1 /* Data input available */
362 #define POLL_OUT 2 /* Output buffers available */
363 #define POLL_MSG 3 /* Input message available */
364 #define POLL_ERR 4 /* I/O Error */
365 #define POLL_PRI 5 /* High priority input available */
366 #define POLL_HUP 6 /* Device disconnected */
367
368 #endif
369
370 #if __POSIX_VISIBLE || __XSI_VISIBLE
371 struct __siginfo;
372
373 /*
374 _ Signal vector "template" used in sigaction call._*
375 */
376 struct sigaction {
377 union {
378 void (__sa_handler)(int);
379 void (_sa_sigaction)(int, struct __siginfo *, void *);
380 } _sigaction_u; **/* signal handler /_*
381 int sa_flags; **/* see signal options below /_*
382 sigset_t sa_mask; /* signal mask to apply */
383 };
384
385 #define sa_handler _sigaction_u._sa_handler
386 #endif
387
388 #if __XSI_VISIBLE
389 **/* If SASIGINFO is set, sasigaction must be used instead of sahandler. /_*
390 #define sa_sigaction _sigaction_u._sa_sigaction
391 #endif
392
393 #if __POSIX_VISIBLE || __XSI_VISIBLE
394 #define SA_NOCLDSTOP 0x0008 **/* do not generate SIGCHLD on child stop /_*
395 #endif **/* POSIXVISIBLE || XSIVISIBLE */**
396
397 #if __XSI_VISIBLE
398 #define SA_ONSTACK 0x0001 **/* take signal on signal stack /_*
399 #define SA_RESTART 0x0002 **/* restart system call on signal return /_*
400 #define SA_RESETHAND 0x0004 /* reset to SIGDFL when taking signal */
401 #define SA_NODEFER 0x0010 /* don't mask the signal we're delivering */
402 #define SA_NOCLDWAIT 0x0020 /* don't keep zombies around */
403 #define SA_SIGINFO 0x0040 /* signal handler with SASIGINFO args */
404 #endif
405
406 #if __BSD_VISIBLE
407 #define NSIG 32 /* number of old signals (counting 0) */
408 #endif
409
410 #if __POSIX_VISIBLE || __XSI_VISIBLE
411 #define SI_NOINFO 0 /* No signal info besides sisigno. */
412 #define SI_USER 0x10001 /* Signal sent by kill(). */
413 #define SI_QUEUE 0x10002 /* Signal sent by the sigqueue(). */
414 #define SI_TIMER 0x10003 /* Signal generated by expiration of */
415 /* a timer set by timersettime(). */
416 #define SI_ASYNCIO 0x10004 /* Signal generated by completion of */
417 /* an asynchronous I/O request.*/
418 #define SI_MESGQ 0x10005 /* Signal generated by arrival of a */
419 /* message on an empty message queue. */
420 #define SI_KERNEL 0x10006
421 #define SI_LWP 0x10007 /* Signal sent by thrkill */
422 #endif
423 #if __BSD_VISIBLE
424 #define SI_UNDEFINED 0
425 #endif
426
427 #if __BSD_VISIBLE
428 typedef __sighandler_t sig_t; /* type of pointer to a signal function */
429 typedef void __siginfohandler_t(int, struct __siginfo , void );
430 #endif
431
432 #if __XSI_VISIBLE
433 #if __BSD_VISIBLE
434 #define __stack_t sigaltstack
435 #endif
436 typedef struct __stack_t stack_t;
437
438 #define SS_ONSTACK 0x0001 /* take signal on alternate stack */
439 #define SS_DISABLE 0x0004 /* disable taking signals on alternate stack */
440 #define MINSIGSTKSZ __MINSIGSTKSZ /* minimum stack size */
441 #define SIGSTKSZ (MINSIGSTKSZ + 32768) /* recommended stack size */
442 #endif
443
444 **_/_
445 _ Structure used in sigaltstack call. Its definition is always_
446 _ needed for _ucontext. If BSDVISIBLE is defined, the structure
447 _ tag is actually sigaltstack._*
448 */
449 struct __stack_t {
450 void ss_sp; /* signal stack base */
451 __size_t ss_size; /* signal stack length */
452 int ss_flags; /* SSDISABLE and/or SSONSTACK */
453 };
454
455 #if __BSD_VISIBLE
456 **_/_
457 _ 4.3 compatibility:_*
458 _ Signal vector "template" used in sigvec call._*
459 */
460 struct sigvec {
461 __sighandler_t sv_handler; /* signal handler */
462 int sv_mask; /* signal mask to apply */
463 int sv_flags; /* see signal options below */
464 };
465
466 #define SV_ONSTACK SA_ONSTACK
467 #define SV_INTERRUPT SA_RESTART /* same bit, opposite sense */
468 #define SV_RESETHAND SA_RESETHAND
469 #define SV_NODEFER SA_NODEFER
470 #define SV_NOCLDSTOP SA_NOCLDSTOP
471 #define SV_SIGINFO SA_SIGINFO
472 #define sv_onstack sv_flags /* isn't compatibility wonderful! */
473 #endif
474
475 /* Keep this in one place only */
476 #if defined(_KERNEL) && defined(COMPAT_43) &&
477 !defined(i386)
478 struct osigcontext {
479 int not_used;
480 };
481 #endif
482
483 #if __XSI_VISIBLE
484 **/_
485 _ Structure used in sigstack call._*
486 */
487 struct sigstack {
488 void ss_sp; /* signal stack pointer */
489 int ss_onstack; /* current status */
490 };
491 #endif
492
493 #if __BSD_VISIBLE || __POSIX_VISIBLE > 0 && __POSIX_VISIBLE <= 200112
494 **_/*_**
495 **_* Macro for converting signal number to a mask suitable for_**
496 **_* sigblock().**
497 */
498 #define sigmask(m) (1 << ((m)-1))
499 #endif
500
501 #if __BSD_VISIBLE
502 #define BADSIG SIG_ERR
503 #endif
504
505 #if __POSIX_VISIBLE || __XSI_VISIBLE
506 **_/*_**
507 **_* Flags for sigprocmask:_**
508 **_*/_**
509 #define SIG_BLOCK 1 **_/* block specified signal set */_**
510 #define SIG_UNBLOCK 2 **_/* unblock specified signal set */_**
511 #define SIG_SETMASK 3 **_/* set specified signal set */_**
512 #endif
513
514 **_/*_**
515 **_* For historical reasons; programs expect signal's return value to be_**
516 **_* defined by <sys/signal.h>.*
517 */
518 __BEGIN_DECLS
519 __sighandler_t *signal(int, __sighandler_t *);
520 __END_DECLS
521
522 #endif /* !SYSSIGNALH */
Cache object: 39b83d6fd4f9a7585bb8f96ef7da2a6f