root / lab4 / .minix-src / include / sys / signal.h @ 13
History | View | Annotate | Download (10.6 KB)
1 |
/* $NetBSD: signal.h,v 1.67 2011/01/10 13:56:44 christos Exp $ */
|
---|---|
2 |
|
3 |
/*
|
4 |
* Copyright (c) 1982, 1986, 1989, 1991, 1993
|
5 |
* The Regents of the University of California. All rights reserved.
|
6 |
* (c) UNIX System Laboratories, Inc.
|
7 |
* All or some portions of this file are derived from material licensed
|
8 |
* to the University of California by American Telephone and Telegraph
|
9 |
* 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 |
*/
|
38 |
|
39 |
#ifndef _SYS_SIGNAL_H_
|
40 |
#define _SYS_SIGNAL_H_
|
41 |
|
42 |
#include <sys/featuretest.h> |
43 |
#include <sys/sigtypes.h> |
44 |
|
45 |
#define _NSIG 64 |
46 |
|
47 |
#if defined(_NETBSD_SOURCE)
|
48 |
#define NSIG _NSIG
|
49 |
|
50 |
#endif /* _NETBSD_SOURCE */ |
51 |
|
52 |
#define SIGHUP 1 /* hangup */ |
53 |
#define SIGINT 2 /* interrupt */ |
54 |
#define SIGQUIT 3 /* quit */ |
55 |
#define SIGILL 4 /* illegal instruction (not reset when caught) */ |
56 |
#define SIGTRAP 5 /* trace trap (not reset when caught) */ |
57 |
#define SIGABRT 6 /* abort() */ |
58 |
#define SIGIOT SIGABRT /* compatibility */ |
59 |
#define SIGEMT 7 /* EMT instruction */ |
60 |
#define SIGFPE 8 /* floating point exception */ |
61 |
#define SIGKILL 9 /* kill (cannot be caught or ignored) */ |
62 |
#define SIGBUS 10 /* bus error */ |
63 |
#define SIGSEGV 11 /* segmentation violation */ |
64 |
#define SIGSYS 12 /* bad argument to system call */ |
65 |
#define SIGPIPE 13 /* write on a pipe with no one to read it */ |
66 |
#define SIGALRM 14 /* alarm clock */ |
67 |
#define SIGTERM 15 /* software termination signal from kill */ |
68 |
#define SIGURG 16 /* urgent condition on IO channel */ |
69 |
#define SIGSTOP 17 /* sendable stop signal not from tty */ |
70 |
#define SIGTSTP 18 /* stop signal from tty */ |
71 |
#define SIGCONT 19 /* continue a stopped process */ |
72 |
#define SIGCHLD 20 /* to parent on child stop or exit */ |
73 |
#define SIGTTIN 21 /* to readers pgrp upon background tty read */ |
74 |
#define SIGTTOU 22 /* like TTIN for output if (tp->t_local<OSTOP) */ |
75 |
#define SIGIO 23 /* input/output possible signal */ |
76 |
#define SIGXCPU 24 /* exceeded CPU time limit */ |
77 |
#define SIGXFSZ 25 /* exceeded file size limit */ |
78 |
#define SIGVTALRM 26 /* virtual time alarm */ |
79 |
#define SIGPROF 27 /* profiling time alarm */ |
80 |
#define SIGWINCH 28 /* window size changes */ |
81 |
#define SIGINFO 29 /* information request */ |
82 |
#define SIGUSR1 30 /* user defined signal 1 */ |
83 |
#define SIGUSR2 31 /* user defined signal 2 */ |
84 |
#define SIGPWR 32 /* power fail/restart (not reset when caught) */ |
85 |
|
86 |
#if !defined(__minix)
|
87 |
#ifdef _KERNEL
|
88 |
#define SIGRTMIN 33 /* Kernel only; not exposed to userland yet */ |
89 |
#define SIGRTMAX 63 /* Kernel only; not exposed to userland yet */ |
90 |
#endif
|
91 |
#endif /* !defined(__minix) */ |
92 |
|
93 |
#ifndef _KERNEL
|
94 |
#include <sys/cdefs.h> |
95 |
#endif
|
96 |
|
97 |
#define SIG_DFL ((void (*)(int)) 0) |
98 |
#define SIG_IGN ((void (*)(int)) 1) |
99 |
#define SIG_ERR ((void (*)(int)) -1) |
100 |
#define SIG_HOLD ((void (*)(int)) 3) |
101 |
|
102 |
#if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \
|
103 |
defined(_NETBSD_SOURCE) |
104 |
|
105 |
#ifdef _KERNEL
|
106 |
#define sigaddset(s, n) __sigaddset(s, n)
|
107 |
#define sigdelset(s, n) __sigdelset(s, n)
|
108 |
#define sigismember(s, n) __sigismember(s, n)
|
109 |
#define sigemptyset(s) __sigemptyset(s)
|
110 |
#define sigfillset(s) __sigfillset(s)
|
111 |
#define sigplusset(s, t) __sigplusset(s, t)
|
112 |
#define sigminusset(s, t) __sigminusset(s, t)
|
113 |
#endif /* _KERNEL */ |
114 |
|
115 |
#if (_POSIX_C_SOURCE - 0) >= 199309L || (_XOPEN_SOURCE - 0) >= 500 || \ |
116 |
defined(_NETBSD_SOURCE) |
117 |
#include <sys/siginfo.h> |
118 |
#endif
|
119 |
|
120 |
#if (defined(_XOPEN_SOURCE) && defined(_XOPEN_SOURCE_EXTENDED)) || \
|
121 |
(_XOPEN_SOURCE - 0) >= 500 || defined(_NETBSD_SOURCE) |
122 |
#include <sys/ucontext.h> |
123 |
#endif /* _XOPEN_SOURCE_EXTENDED || _XOPEN_SOURCE >= 500 || _NETBSD_SOURCE */ |
124 |
|
125 |
/*
|
126 |
* Signal vector "template" used in sigaction call.
|
127 |
*/
|
128 |
struct sigaction {
|
129 |
union {
|
130 |
void (*_sa_handler)(int); |
131 |
#if (_POSIX_C_SOURCE - 0) >= 199309L || (_XOPEN_SOURCE - 0) >= 500 || \ |
132 |
defined(_NETBSD_SOURCE) |
133 |
void (*_sa_sigaction)(int, siginfo_t *, void *); |
134 |
#endif
|
135 |
} _sa_u; /* signal handler */
|
136 |
sigset_t sa_mask; /* signal mask to apply */
|
137 |
int sa_flags; /* see signal options below */ |
138 |
}; |
139 |
|
140 |
#define sa_handler _sa_u._sa_handler
|
141 |
#if (_POSIX_C_SOURCE - 0) >= 199309L || (_XOPEN_SOURCE - 0) >= 500 || \ |
142 |
defined(_NETBSD_SOURCE) |
143 |
#define sa_sigaction _sa_u._sa_sigaction
|
144 |
#endif
|
145 |
|
146 |
#include <machine/signal.h> /* sigcontext; codes for SIGILL, SIGFPE */ |
147 |
|
148 |
#if (defined(_XOPEN_SOURCE) && defined(_XOPEN_SOURCE_EXTENDED)) || \
|
149 |
(_XOPEN_SOURCE - 0) >= 500 || defined(_NETBSD_SOURCE) |
150 |
#define SA_ONSTACK 0x0001 /* take signal on signal stack */ |
151 |
#define SA_RESTART 0x0002 /* restart system call on signal return */ |
152 |
#define SA_RESETHAND 0x0004 /* reset to SIG_DFL when taking signal */ |
153 |
#define SA_NODEFER 0x0010 /* don't mask the signal we're delivering */ |
154 |
#endif /* _XOPEN_SOURCE_EXTENDED || XOPEN_SOURCE >= 500 || _NETBSD_SOURCE */ |
155 |
/* Only valid for SIGCHLD. */
|
156 |
#define SA_NOCLDSTOP 0x0008 /* do not generate SIGCHLD on child stop */ |
157 |
#define SA_NOCLDWAIT 0x0020 /* do not generate zombies on unwaited child */ |
158 |
#if (_POSIX_C_SOURCE - 0) >= 199309L || (_XOPEN_SOURCE - 0) >= 500 || \ |
159 |
defined(_NETBSD_SOURCE) |
160 |
#if !defined(__minix)
|
161 |
#define SA_SIGINFO 0x0040 /* take sa_sigaction handler */ |
162 |
#endif /* !defined(__minix) */ |
163 |
#endif /* (_POSIX_C_SOURCE - 0) >= 199309L || ... */ |
164 |
#if defined(_NETBSD_SOURCE)
|
165 |
#define SA_NOKERNINFO 0x0080 /* siginfo does not print kernel info on tty */ |
166 |
#endif /*_NETBSD_SOURCE */ |
167 |
#ifdef _KERNEL
|
168 |
#define SA_ALLBITS 0x00ff |
169 |
#endif
|
170 |
|
171 |
/*
|
172 |
* Flags for sigprocmask():
|
173 |
*/
|
174 |
#define SIG_BLOCK 1 /* block specified signal set */ |
175 |
#define SIG_UNBLOCK 2 /* unblock specified signal set */ |
176 |
#define SIG_SETMASK 3 /* set specified signal set */ |
177 |
|
178 |
#if defined(__minix)
|
179 |
#define SIG_INQUIRE 10 /* for internal use only */ |
180 |
#endif /* defined(__minix) */ |
181 |
|
182 |
#if defined(_NETBSD_SOURCE)
|
183 |
typedef void (*sig_t)(int); /* type of signal function */ |
184 |
#endif
|
185 |
|
186 |
#if (defined(_XOPEN_SOURCE) && defined(_XOPEN_SOURCE_EXTENDED)) || \
|
187 |
(_XOPEN_SOURCE - 0) >= 500 || defined(_NETBSD_SOURCE) |
188 |
/*
|
189 |
* Flags used with stack_t/struct sigaltstack.
|
190 |
*/
|
191 |
#define SS_ONSTACK 0x0001 /* take signals on alternate stack */ |
192 |
#define SS_DISABLE 0x0004 /* disable taking signals on alternate stack */ |
193 |
#ifdef _KERNEL
|
194 |
#define SS_ALLBITS 0x0005 |
195 |
#endif
|
196 |
#define MINSIGSTKSZ 8192 /* minimum allowable stack */ |
197 |
#define SIGSTKSZ (MINSIGSTKSZ + 32768) /* recommended stack size */ |
198 |
#endif /* _XOPEN_SOURCE_EXTENDED || _XOPEN_SOURCE >= 500 || _NETBSD_SOURCE */ |
199 |
|
200 |
#if (defined(_XOPEN_SOURCE) && defined(_XOPEN_SOURCE_EXTENDED)) || \
|
201 |
(_XOPEN_SOURCE - 0) >= 500 || defined(_NETBSD_SOURCE) |
202 |
/*
|
203 |
* Structure used in sigstack call.
|
204 |
*/
|
205 |
struct sigstack {
|
206 |
void *ss_sp; /* signal stack pointer */ |
207 |
int ss_onstack; /* current status */ |
208 |
}; |
209 |
#endif /* _XOPEN_SOURCE_EXTENDED || _XOPEN_SOURCE >= 500 || _NETBSD_SOURCE */ |
210 |
|
211 |
#if defined(_NETBSD_SOURCE) && !defined(_KERNEL)
|
212 |
/*
|
213 |
* Macro for converting signal number to a mask suitable for
|
214 |
* sigblock().
|
215 |
*/
|
216 |
#define sigmask(n) __sigmask(n)
|
217 |
|
218 |
#define BADSIG SIG_ERR
|
219 |
#endif /* _NETBSD_SOURCE */ |
220 |
|
221 |
#if (_POSIX_C_SOURCE - 0) >= 199309L || (_XOPEN_SOURCE - 0) >= 500 || \ |
222 |
defined(_NETBSD_SOURCE) |
223 |
struct sigevent {
|
224 |
int sigev_notify;
|
225 |
int sigev_signo;
|
226 |
union sigval sigev_value;
|
227 |
void (*sigev_notify_function)(union sigval); |
228 |
void /* pthread_attr_t */ *sigev_notify_attributes; |
229 |
}; |
230 |
|
231 |
#define SIGEV_NONE 0 |
232 |
#define SIGEV_SIGNAL 1 |
233 |
#define SIGEV_THREAD 2 |
234 |
#if defined(_NETBSD_SOURCE)
|
235 |
#define SIGEV_SA 3 |
236 |
#endif
|
237 |
#endif /* (_POSIX_C_SOURCE - 0) >= 199309L || ... */ |
238 |
|
239 |
#endif /* _POSIX_C_SOURCE || _XOPEN_SOURCE || _NETBSD_SOURCE */ |
240 |
|
241 |
/*
|
242 |
* For historical reasons; programs expect signal's return value to be
|
243 |
* defined by <sys/signal.h>.
|
244 |
*/
|
245 |
__BEGIN_DECLS |
246 |
void (*signal(int, void (*)(int)))(int); |
247 |
#if (_POSIX_C_SOURCE - 0) >= 200112L || defined(_NETBSD_SOURCE) |
248 |
int sigqueue(pid_t, int, const union sigval); |
249 |
#endif
|
250 |
#if defined(_NETBSD_SOURCE)
|
251 |
int sigqueueinfo(pid_t, const siginfo_t *); |
252 |
#endif
|
253 |
__END_DECLS |
254 |
|
255 |
#if defined(__minix) && defined(_NETBSD_SOURCE)
|
256 |
|
257 |
/* MINIX specific signals. These signals are not used by user proceses,
|
258 |
* but meant to inform system processes, like the PM, about system events.
|
259 |
* The order here determines the order signals are processed by system
|
260 |
* processes in user-space. Higher-priority signals should be first.
|
261 |
*/
|
262 |
/* Signals delivered by a signal manager. */
|
263 |
|
264 |
#define SIGSNDELAY 70 /* end of delay for signal delivery */ |
265 |
|
266 |
#define SIGS_FIRST SIGHUP /* first system signal */ |
267 |
#define SIGS_LAST SIGSNDELAY /* last system signal */ |
268 |
#define IS_SIGS(signo) (signo>=SIGS_FIRST && signo<=SIGS_LAST)
|
269 |
|
270 |
/* Signals delivered by the kernel. */
|
271 |
#define SIGKMEM 71 /* kernel memory request pending */ |
272 |
#define SIGKMESS 72 /* new kernel message */ |
273 |
#define SIGKSIGSM 73 /* kernel signal pending for signal manager */ |
274 |
#define SIGKSIG 74 /* kernel signal pending */ |
275 |
|
276 |
#define SIGK_FIRST SIGKMEM /* first kernel signal */ |
277 |
#define SIGK_LAST SIGKSIG /* last kernel signal; _NSIG must cover it! */ |
278 |
#define IS_SIGK(signo) (signo>=SIGK_FIRST && signo<=SIGK_LAST)
|
279 |
|
280 |
/* Termination signals for Minix system processes. */
|
281 |
#define SIGS_IS_LETHAL(sig) \
|
282 |
(sig == SIGILL || sig == SIGBUS || sig == SIGFPE || sig == SIGSEGV \ |
283 |
|| sig == SIGEMT || sig == SIGABRT) |
284 |
#define SIGS_IS_TERMINATION(sig) (SIGS_IS_LETHAL(sig) \
|
285 |
|| (sig == SIGKILL || sig == SIGPIPE)) |
286 |
#define SIGS_IS_STACKTRACE(sig) (SIGS_IS_LETHAL(sig) && sig != SIGABRT)
|
287 |
|
288 |
#endif /* defined(__minix) && defined(_NETBSD_SOURCE) */ |
289 |
|
290 |
#endif /* !_SYS_SIGNAL_H_ */ |