]>
git.saurik.com Git - apple/xnu.git/blob - bsd/sys/signal.h
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
22 /* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */
24 * Copyright (c) 1982, 1986, 1989, 1991, 1993
25 * The Regents of the University of California. All rights reserved.
26 * (c) UNIX System Laboratories, Inc.
27 * All or some portions of this file are derived from material licensed
28 * to the University of California by American Telephone and Telegraph
29 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
30 * the permission of UNIX System Laboratories, Inc.
32 * Redistribution and use in source and binary forms, with or without
33 * modification, are permitted provided that the following conditions
35 * 1. Redistributions of source code must retain the above copyright
36 * notice, this list of conditions and the following disclaimer.
37 * 2. Redistributions in binary form must reproduce the above copyright
38 * notice, this list of conditions and the following disclaimer in the
39 * documentation and/or other materials provided with the distribution.
40 * 3. All advertising materials mentioning features or use of this software
41 * must display the following acknowledgement:
42 * This product includes software developed by the University of
43 * California, Berkeley and its contributors.
44 * 4. Neither the name of the University nor the names of its contributors
45 * may be used to endorse or promote products derived from this software
46 * without specific prior written permission.
48 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
49 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
50 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
51 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
52 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
53 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
54 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
55 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
56 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
57 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
60 * @(#)signal.h 8.2 (Berkeley) 1/21/94
63 #ifndef _SYS_SIGNAL_H_
64 #define _SYS_SIGNAL_H_
66 #if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
67 #define NSIG 32 /* counting 0; could be 33 (mask is 1-32) */
70 #include <machine/signal.h> /* sigcontext; codes for SIGILL, SIGFPE */
72 #define SIGHUP 1 /* hangup */
73 #define SIGINT 2 /* interrupt */
74 #define SIGQUIT 3 /* quit */
75 #define SIGILL 4 /* illegal instruction (not reset when caught) */
76 #if !defined(_POSIX_SOURCE)
77 #define SIGTRAP 5 /* trace trap (not reset when caught) */
79 #define SIGABRT 6 /* abort() */
80 #if !defined(_POSIX_SOURCE)
81 #define SIGIOT SIGABRT /* compatibility */
82 #define SIGEMT 7 /* EMT instruction */
84 #define SIGFPE 8 /* floating point exception */
85 #define SIGKILL 9 /* kill (cannot be caught or ignored) */
86 #if !defined(_POSIX_SOURCE)
87 #define SIGBUS 10 /* bus error */
89 #define SIGSEGV 11 /* segmentation violation */
90 #if !defined(_POSIX_SOURCE)
91 #define SIGSYS 12 /* bad argument to system call */
93 #define SIGPIPE 13 /* write on a pipe with no one to read it */
94 #define SIGALRM 14 /* alarm clock */
95 #define SIGTERM 15 /* software termination signal from kill */
96 #if !defined(_POSIX_SOURCE)
97 #define SIGURG 16 /* urgent condition on IO channel */
99 #define SIGSTOP 17 /* sendable stop signal not from tty */
100 #define SIGTSTP 18 /* stop signal from tty */
101 #define SIGCONT 19 /* continue a stopped process */
102 #define SIGCHLD 20 /* to parent on child stop or exit */
103 #define SIGTTIN 21 /* to readers pgrp upon background tty read */
104 #define SIGTTOU 22 /* like TTIN for output if (tp->t_local<OSTOP) */
105 #if !defined(_POSIX_SOURCE)
106 #define SIGIO 23 /* input/output possible signal */
107 #define SIGXCPU 24 /* exceeded CPU time limit */
108 #define SIGXFSZ 25 /* exceeded file size limit */
109 #define SIGVTALRM 26 /* virtual time alarm */
110 #define SIGPROF 27 /* profiling time alarm */
111 #define SIGWINCH 28 /* window size changes */
112 #define SIGINFO 29 /* information request */
114 #define SIGUSR1 30 /* user defined signal 1 */
115 #define SIGUSR2 31 /* user defined signal 2 */
117 #if defined(_ANSI_SOURCE) || defined(__cplusplus)
119 * Language spec sez we must list exactly one parameter, even though we
120 * actually supply three. Ugh!
122 #define SIG_DFL (void (*)(int))0
123 #define SIG_IGN (void (*)(int))1
124 #define SIG_ERR (void (*)(int))-1
126 #define SIG_DFL (void (*)())0
127 #define SIG_IGN (void (*)())1
128 #define SIG_ERR (void (*)())-1
132 typedef unsigned int sigset_t
;
135 * Signal vector "template" used in sigaction call.
138 #if defined(__cplusplus)
139 void (*sa_handler
)(int); /* signal handler */
141 void (*sa_handler
)(); /* signal handler */
142 #endif /* __cplusplus */
143 sigset_t sa_mask
; /* signal mask to apply */
144 int sa_flags
; /* see signal options below */
146 #if !defined(_POSIX_SOURCE)
147 #define SA_ONSTACK 0x0001 /* take signal on signal stack */
148 #define SA_RESTART 0x0002 /* restart system on signal return */
149 #define SA_DISABLE 0x0004 /* disable taking signals on alternate stack */
150 #define SA_USERTRAMP 0x0100 /* do not bounce off kernel's sigtramp */
152 #define SA_NOCLDSTOP 0x0008 /* do not generate SIGCHLD on child stop */
155 * Flags for sigprocmask:
157 #define SIG_BLOCK 1 /* block specified signal set */
158 #define SIG_UNBLOCK 2 /* unblock specified signal set */
159 #define SIG_SETMASK 3 /* set specified signal set */
161 #if !defined(_POSIX_SOURCE)
162 #include <sys/cdefs.h>
163 typedef void (*sig_t
) __P((int)); /* type of signal function */
166 * Structure used in sigaltstack call.
169 char *ss_sp
; /* signal stack base */
170 int ss_size
; /* signal stack length */
171 int ss_flags
; /* SA_DISABLE and/or SA_ONSTACK */
173 #define MINSIGSTKSZ 8192 /* minimum allowable stack */
174 #define SIGSTKSZ (MINSIGSTKSZ + 32768) /* recommended stack size */
178 * Signal vector "template" used in sigvec call.
181 void (*sv_handler
)(); /* signal handler */
182 int sv_mask
; /* signal mask to apply */
183 int sv_flags
; /* see signal options below */
186 #define SV_ONSTACK SA_ONSTACK
187 #define SV_INTERRUPT SA_RESTART /* same bit, opposite sense */
188 #define sv_onstack sv_flags /* isn't compatibility wonderful! */
191 * Structure used in sigstack call.
194 char *ss_sp
; /* signal stack pointer */
195 int ss_onstack
; /* current status */
199 * Macro for converting signal number to a mask suitable for
202 #define sigmask(m) (1 << ((m)-1))
206 * signals delivered on a per-thread basis.
208 #define threadmask (sigmask(SIGILL)|sigmask(SIGTRAP)|\
209 sigmask(SIGIOT)|sigmask(SIGEMT)|\
210 sigmask(SIGFPE)|sigmask(SIGBUS)|\
211 sigmask(SIGSEGV)|sigmask(SIGSYS)|\
215 #define BADSIG SIG_ERR
217 #endif /* !_POSIX_SOURCE */
218 #endif /* !_ANSI_SOURCE */
221 * For historical reasons; programs expect signal's return value to be
222 * defined by <sys/signal.h>.
225 void (*signal
__P((int, void (*) __P((int))))) __P((int));
227 #endif /* !_SYS_SIGNAL_H_ */