]> git.saurik.com Git - apple/xnu.git/blame - bsd/sys/signal.h
xnu-124.13.tar.gz
[apple/xnu.git] / bsd / sys / signal.h
CommitLineData
1c79356b
A
1/*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
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.
11 *
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
18 * under the License.
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22/* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */
23/*
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.
31 *
32 * Redistribution and use in source and binary forms, with or without
33 * modification, are permitted provided that the following conditions
34 * are met:
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.
47 *
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
58 * SUCH DAMAGE.
59 *
60 * @(#)signal.h 8.2 (Berkeley) 1/21/94
61 */
62
63#ifndef _SYS_SIGNAL_H_
64#define _SYS_SIGNAL_H_
65
66#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
67#define NSIG 32 /* counting 0; could be 33 (mask is 1-32) */
68#endif
69
70#include <machine/signal.h> /* sigcontext; codes for SIGILL, SIGFPE */
71
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) */
78#endif
79#define SIGABRT 6 /* abort() */
80#if !defined(_POSIX_SOURCE)
81#define SIGIOT SIGABRT /* compatibility */
82#define SIGEMT 7 /* EMT instruction */
83#endif
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 */
88#endif
89#define SIGSEGV 11 /* segmentation violation */
90#if !defined(_POSIX_SOURCE)
91#define SIGSYS 12 /* bad argument to system call */
92#endif
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 */
98#endif
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&LTOSTOP) */
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 */
113#endif
114#define SIGUSR1 30 /* user defined signal 1 */
115#define SIGUSR2 31 /* user defined signal 2 */
116
117#if defined(_ANSI_SOURCE) || defined(__cplusplus)
118/*
119 * Language spec sez we must list exactly one parameter, even though we
120 * actually supply three. Ugh!
121 */
122#define SIG_DFL (void (*)(int))0
123#define SIG_IGN (void (*)(int))1
124#define SIG_ERR (void (*)(int))-1
125#else
126#define SIG_DFL (void (*)())0
127#define SIG_IGN (void (*)())1
128#define SIG_ERR (void (*)())-1
129#endif
130
131#ifndef _ANSI_SOURCE
132typedef unsigned int sigset_t;
133
134/*
135 * Signal vector "template" used in sigaction call.
136 */
137struct sigaction {
138#if defined(__cplusplus)
139 void (*sa_handler)(int); /* signal handler */
140#else
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 */
145};
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 */
151#endif
152#define SA_NOCLDSTOP 0x0008 /* do not generate SIGCHLD on child stop */
153
154/*
155 * Flags for sigprocmask:
156 */
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 */
160
161#if !defined(_POSIX_SOURCE)
162#include <sys/cdefs.h>
163typedef void (*sig_t) __P((int)); /* type of signal function */
164
165/*
166 * Structure used in sigaltstack call.
167 */
168struct sigaltstack {
169 char *ss_sp; /* signal stack base */
170 int ss_size; /* signal stack length */
171 int ss_flags; /* SA_DISABLE and/or SA_ONSTACK */
172};
173#define MINSIGSTKSZ 8192 /* minimum allowable stack */
174#define SIGSTKSZ (MINSIGSTKSZ + 32768) /* recommended stack size */
175
176/*
177 * 4.3 compatibility:
178 * Signal vector "template" used in sigvec call.
179 */
180struct sigvec {
181 void (*sv_handler)(); /* signal handler */
182 int sv_mask; /* signal mask to apply */
183 int sv_flags; /* see signal options below */
184};
185
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! */
189
190/*
191 * Structure used in sigstack call.
192 */
193struct sigstack {
194 char *ss_sp; /* signal stack pointer */
195 int ss_onstack; /* current status */
196};
197
198/*
199 * Macro for converting signal number to a mask suitable for
200 * sigblock().
201 */
202#define sigmask(m) (1 << ((m)-1))
203
204#ifdef KERNEL
205 /*
206 * signals delivered on a per-thread basis.
207 */
208 #define threadmask (sigmask(SIGILL)|sigmask(SIGTRAP)|\
209 sigmask(SIGIOT)|sigmask(SIGEMT)|\
210 sigmask(SIGFPE)|sigmask(SIGBUS)|\
211 sigmask(SIGSEGV)|sigmask(SIGSYS)|\
212 sigmask(SIGPIPE))
213#endif /* KERNEL */
214
215#define BADSIG SIG_ERR
216
217#endif /* !_POSIX_SOURCE */
218#endif /* !_ANSI_SOURCE */
219
220/*
221 * For historical reasons; programs expect signal's return value to be
222 * defined by <sys/signal.h>.
223 */
224__BEGIN_DECLS
225void (*signal __P((int, void (*) __P((int))))) __P((int));
226__END_DECLS
227#endif /* !_SYS_SIGNAL_H_ */