FreeBSD/Linux Kernel Cross Reference
sys/sys/signal.h
1 /* $OpenBSD: signal.h,v 1.29 2018/04/18 16:05:20 deraadt Exp $ */
2 /* $NetBSD: signal.h,v 1.21 1996/02/09 18:25:32 christos Exp $ */
3
4 /*
5 * Copyright (c) 1982, 1986, 1989, 1991, 1993
6 * The Regents of the University of California. All rights reserved.
7 * (c) UNIX System Laboratories, Inc.
8 * All or some portions of this file are derived from material licensed
9 * to the University of California by American Telephone and Telegraph
10 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
11 * the permission of UNIX System Laboratories, Inc.
12 *
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
15 * are met:
16 * 1. Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 * 2. Redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the distribution.
21 * 3. Neither the name of the University nor the names of its contributors
22 * may be used to endorse or promote products derived from this software
23 * without specific prior written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 * SUCH DAMAGE.
36 *
37 * @(#)signal.h 8.2 (Berkeley) 1/21/94
38 */
39
40 #ifndef _SYS_SIGNAL_H_
41 #define _SYS_SIGNAL_H_
42
43 #include <machine/signal.h> /* sigcontext; codes for SIGILL, SIGFPE */
44
45 #define _NSIG 33 /* counting 0 (mask is 1-32) */
46
47 #if __BSD_VISIBLE
48 #define NSIG _NSIG
49 #endif
50
51 #define SIGHUP 1 /* hangup */
52 #define SIGINT 2 /* interrupt */
53 #define SIGQUIT 3 /* quit */
54 #define SIGILL 4 /* illegal instruction (not reset when caught) */
55 #define SIGTRAP 5 /* trace trap (not reset when caught) */
56 #define SIGABRT 6 /* abort() */
57 #if __BSD_VISIBLE
58 #define SIGIOT SIGABRT /* compatibility */
59 #define SIGEMT 7 /* EMT instruction */
60 #endif
61 #define SIGFPE 8 /* floating point exception */
62 #define SIGKILL 9 /* kill (cannot be caught or ignored) */
63 #define SIGBUS 10 /* bus error */
64 #define SIGSEGV 11 /* segmentation violation */
65 #define SIGSYS 12 /* bad argument to system call */
66 #define SIGPIPE 13 /* write on a pipe with no one to read it */
67 #define SIGALRM 14 /* alarm clock */
68 #define SIGTERM 15 /* software termination signal from kill */
69 #define SIGURG 16 /* urgent condition on IO channel */
70 #define SIGSTOP 17 /* sendable stop signal not from tty */
71 #define SIGTSTP 18 /* stop signal from tty */
72 #define SIGCONT 19 /* continue a stopped process */
73 #define SIGCHLD 20 /* to parent on child stop or exit */
74 #define SIGTTIN 21 /* to readers pgrp upon background tty read */
75 #define SIGTTOU 22 /* like TTIN for output if (tp->t_local<OSTOP) */
76 #if __BSD_VISIBLE
77 #define SIGIO 23 /* input/output possible signal */
78 #endif
79 #define SIGXCPU 24 /* exceeded CPU time limit */
80 #define SIGXFSZ 25 /* exceeded file size limit */
81 #define SIGVTALRM 26 /* virtual time alarm */
82 #define SIGPROF 27 /* profiling time alarm */
83 #if __BSD_VISIBLE
84 #define SIGWINCH 28 /* window size changes */
85 #define SIGINFO 29 /* information request */
86 #endif
87 #define SIGUSR1 30 /* user defined signal 1 */
88 #define SIGUSR2 31 /* user defined signal 2 */
89 #if __BSD_VISIBLE
90 #define SIGTHR 32 /* thread library AST */
91 #endif
92
93 /*
94 * Language spec says we must list exactly one parameter, even though we
95 * actually supply three. Ugh!
96 */
97 #define SIG_DFL (void (*)(int))0
98 #define SIG_IGN (void (*)(int))1
99 #define SIG_ERR (void (*)(int))-1
100
101 #if __POSIX_VISIBLE || __XPG_VISIBLE
102 #ifndef _SIGSET_T_DEFINED_
103 #define _SIGSET_T_DEFINED_
104 typedef unsigned int sigset_t;
105 #endif
106
107 #include <sys/siginfo.h>
108
109 /*
110 * Signal vector "template" used in sigaction call.
111 */
112 struct sigaction {
113 union { /* signal handler */
114 void (*__sa_handler)(int);
115 void (*__sa_sigaction)(int, siginfo_t *, void *);
116 } __sigaction_u;
117 sigset_t sa_mask; /* signal mask to apply */
118 int sa_flags; /* see signal options below */
119 };
120
121 /* if SA_SIGINFO is set, sa_sigaction is to be used instead of sa_handler. */
122 #define sa_handler __sigaction_u.__sa_handler
123 #define sa_sigaction __sigaction_u.__sa_sigaction
124
125 #if __XPG_VISIBLE >= 500
126 #define SA_ONSTACK 0x0001 /* take signal on signal stack */
127 #define SA_RESTART 0x0002 /* restart system on signal return */
128 #define SA_RESETHAND 0x0004 /* reset to SIG_DFL when taking signal */
129 #define SA_NODEFER 0x0010 /* don't mask the signal we're delivering */
130 #define SA_NOCLDWAIT 0x0020 /* don't create zombies (assign to pid 1) */
131 #endif /* __XPG_VISIBLE >= 500 */
132 #define SA_NOCLDSTOP 0x0008 /* do not generate SIGCHLD on child stop */
133 #if __POSIX_VISIBLE >= 199309 || __XPG_VISIBLE >= 500
134 #define SA_SIGINFO 0x0040 /* generate siginfo_t */
135 #endif
136
137 /*
138 * Flags for sigprocmask:
139 */
140 #define SIG_BLOCK 1 /* block specified signal set */
141 #define SIG_UNBLOCK 2 /* unblock specified signal set */
142 #define SIG_SETMASK 3 /* set specified signal set */
143 #endif /* __POSIX_VISIBLE || __XPG_VISIBLE */
144
145 #if __BSD_VISIBLE
146 typedef void (*sig_t)(int); /* type of signal function */
147
148 /*
149 * 4.3 compatibility:
150 * Signal vector "template" used in sigvec call.
151 */
152 struct sigvec {
153 void (*sv_handler)(int); /* signal handler */
154 int sv_mask; /* signal mask to apply */
155 int sv_flags; /* see signal options below */
156 };
157 #define SV_ONSTACK SA_ONSTACK
158 #define SV_INTERRUPT SA_RESTART /* same bit, opposite sense */
159 #define SV_RESETHAND SA_RESETHAND
160 #define sv_onstack sv_flags /* isn't compatibility wonderful! */
161
162 /*
163 * Macro for converting signal number to a mask suitable for
164 * sigblock().
165 */
166 #define sigmask(m) (1U << ((m)-1))
167
168 #define BADSIG SIG_ERR
169
170 #endif /* __BSD_VISIBLE */
171
172 #if __BSD_VISIBLE || __XPG_VISIBLE >= 420
173 /*
174 * Structure used in sigaltstack call.
175 */
176 typedef struct sigaltstack {
177 void *ss_sp; /* signal stack base */
178 size_t ss_size; /* signal stack length */
179 int ss_flags; /* SS_DISABLE and/or SS_ONSTACK */
180 } stack_t;
181 #define SS_ONSTACK 0x0001 /* take signals on alternate stack */
182 #define SS_DISABLE 0x0004 /* disable taking signals on alternate stack */
183 #define MINSIGSTKSZ (3U << _MAX_PAGE_SHIFT) /* minimum allowable stack */
184 #if _MAX_PAGE_SHIFT < 14 /* recommended stack size */
185 #define SIGSTKSZ (MINSIGSTKSZ + (1U << _MAX_PAGE_SHIFT) * 4)
186 #else
187 #define SIGSTKSZ (MINSIGSTKSZ + (1U << _MAX_PAGE_SHIFT) * 2)
188 #endif
189
190 typedef struct sigcontext ucontext_t;
191 #endif /* __BSD_VISIBLE || __XPG_VISIBLE >= 420 */
192
193 #ifndef _KERNEL
194 /*
195 * For historical reasons; programs expect signal's return value to be
196 * defined by <sys/signal.h>.
197 */
198 __BEGIN_DECLS
199 void (*signal(int, void (*)(int)))(int);
200 __END_DECLS
201 #endif /* !_KERNEL */
202 #endif /* !_SYS_SIGNAL_H_ */
Cache object: 326345ee27980cadbc7ce565c8270dc3
|