]>
git.saurik.com Git - apple/xnu.git/blob - bsd/sys/signalvar.h
2 * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
25 /* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */
27 * Copyright (c) 1991, 1993
28 * The Regents of the University of California. All rights reserved.
30 * Redistribution and use in source and binary forms, with or without
31 * modification, are permitted provided that the following conditions
33 * 1. Redistributions of source code must retain the above copyright
34 * notice, this list of conditions and the following disclaimer.
35 * 2. Redistributions in binary form must reproduce the above copyright
36 * notice, this list of conditions and the following disclaimer in the
37 * documentation and/or other materials provided with the distribution.
38 * 3. All advertising materials mentioning features or use of this software
39 * must display the following acknowledgement:
40 * This product includes software developed by the University of
41 * California, Berkeley and its contributors.
42 * 4. Neither the name of the University nor the names of its contributors
43 * may be used to endorse or promote products derived from this software
44 * without specific prior written permission.
46 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
47 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
48 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
49 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
50 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
51 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
52 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
53 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
54 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
55 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
58 * @(#)signalvar.h 8.3 (Berkeley) 1/4/94
61 #ifndef _SYS_SIGNALVAR_H_ /* tmp for user.h */
62 #define _SYS_SIGNALVAR_H_
64 #include <sys/appleapiopts.h>
66 #ifdef __APPLE_API_PRIVATE
68 * Kernel signal definitions and data structures,
69 * not exported to user programs.
73 * Process signal actions and state, needed only within the process
74 * (not necessarily resident).
77 sig_t ps_sigact
[NSIG
]; /* disposition of signals */
78 sig_t ps_trampact
[NSIG
]; /* disposition of signals */
79 sigset_t ps_catchmask
[NSIG
]; /* signals to be blocked */
80 sigset_t ps_sigonstack
; /* signals to take on sigstack */
81 sigset_t ps_sigintr
; /* signals that interrupt syscalls */
82 sigset_t ps_sigreset
; /* signals that reset when caught */
83 sigset_t ps_signodefer
; /* signals not masked while handled */
84 sigset_t ps_siginfo
; /* signals that want SA_SIGINFO args */
85 sigset_t ps_oldmask
; /* saved mask from before sigpause */
86 int ps_flags
; /* signal flags, below */
87 struct sigaltstack ps_sigstk
; /* sp & on stack state variable */
88 int ps_sig
; /* for core dump/debugger XXX */
89 int ps_code
; /* for core dump/debugger XXX */
90 int ps_addr
; /* for core dump/debugger XXX */
91 sigset_t ps_usertramp
; /* SunOS compat; libc sigtramp XXX */
95 #define SAS_OLDMASK 0x01 /* need to restore mask before pause */
96 #define SAS_ALTSTACK 0x02 /* have alternate signal stack */
98 /* additional signal action values, used only temporarily/internally */
99 #define SIG_CATCH (void (*)())2
100 #define SIG_HOLD (void (*)())3
101 #define SIG_WAIT (void (*)())4
103 #define pgsigio(pgid, sig, notused) \
107 gsignal(-(pgid), sig);\
108 else if (pgid > 0 && (p = pfind(pgid)) != 0) \
113 * get signal action for process and signal; currently only for current process
115 #define SIGACTION(p, sig) (p->p_sigacts->ps_sigact[(sig)])
118 * Check for per-process and per thread signals.
120 #define SHOULDissignal(p,uthreadp) \
121 (((uthreadp)->uu_siglist) \
122 & ~((((uthreadp)->uu_sigmask) \
123 | (((p)->p_flag & P_TRACED) ? 0 : (p)->p_sigignore)) \
127 * Check for signals and per-thread signals.
128 * Use in trap() and syscall() before
131 #define CHECK_SIGNALS(p, thread, uthreadp) \
132 (!thread_should_halt(thread) \
133 && (SHOULDissignal(p,uthreadp)))
136 * Signal properties and actions.
137 * The array below categorizes the signals and their default actions
138 * according to the following properties:
140 #define SA_KILL 0x01 /* terminates process by default */
141 #define SA_CORE 0x02 /* ditto and coredumps */
142 #define SA_STOP 0x04 /* suspend process */
143 #define SA_TTYSTOP 0x08 /* ditto, from tty */
144 #define SA_IGNORE 0x10 /* ignore by default */
145 #define SA_CONT 0x20 /* continue if suspended */
146 #define SA_CANTMASK 0x40 /* non-maskable, catchable */
149 int sigprop
[NSIG
+ 1] = {
151 SA_KILL
, /* SIGHUP */
152 SA_KILL
, /* SIGINT */
153 SA_KILL
|SA_CORE
, /* SIGQUIT */
154 SA_KILL
|SA_CORE
, /* SIGILL */
155 SA_KILL
|SA_CORE
, /* SIGTRAP */
156 SA_KILL
|SA_CORE
, /* SIGABRT */
157 SA_KILL
|SA_CORE
, /* SIGEMT */
158 SA_KILL
|SA_CORE
, /* SIGFPE */
159 SA_KILL
, /* SIGKILL */
160 SA_KILL
|SA_CORE
, /* SIGBUS */
161 SA_KILL
|SA_CORE
, /* SIGSEGV */
162 SA_KILL
|SA_CORE
, /* SIGSYS */
163 SA_KILL
, /* SIGPIPE */
164 SA_KILL
, /* SIGALRM */
165 SA_KILL
, /* SIGTERM */
166 SA_IGNORE
, /* SIGURG */
167 SA_STOP
, /* SIGSTOP */
168 SA_STOP
|SA_TTYSTOP
, /* SIGTSTP */
169 SA_IGNORE
|SA_CONT
, /* SIGCONT */
170 SA_IGNORE
, /* SIGCHLD */
171 SA_STOP
|SA_TTYSTOP
, /* SIGTTIN */
172 SA_STOP
|SA_TTYSTOP
, /* SIGTTOU */
173 SA_IGNORE
, /* SIGIO */
174 SA_KILL
, /* SIGXCPU */
175 SA_KILL
, /* SIGXFSZ */
176 SA_KILL
, /* SIGVTALRM */
177 SA_KILL
, /* SIGPROF */
178 SA_IGNORE
, /* SIGWINCH */
179 SA_IGNORE
, /* SIGINFO */
180 SA_KILL
, /* SIGUSR1 */
181 SA_KILL
, /* SIGUSR2 */
184 #define contsigmask (sigmask(SIGCONT))
185 #define stopsigmask (sigmask(SIGSTOP) | sigmask(SIGTSTP) | \
186 sigmask(SIGTTIN) | sigmask(SIGTTOU))
190 #define sigcantmask (sigmask(SIGKILL) | sigmask(SIGSTOP))
194 * Machine-independent functions:
196 int coredump
__P((struct proc
*p
));
197 void execsigs
__P((struct proc
*p
, thread_act_t thr_act
));
198 void gsignal
__P((int pgid
, int sig
));
199 int issignal
__P((struct proc
*p
));
200 int CURSIG
__P((struct proc
*p
));
201 int clear_procsiglist
__P((struct proc
*p
, int bit
));
202 int clear_procsigmask
__P((struct proc
*p
, int bit
));
203 int set_procsigmask
__P((struct proc
*p
, int bit
));
204 void tty_pgsignal
__P((struct pgrp
*pgrp
, int sig
));
205 void postsig
__P((int sig
));
206 void siginit
__P((struct proc
*p
));
207 void trapsignal
__P((struct proc
*p
, int sig
, unsigned code
));
208 void pt_setrunnable
__P((struct proc
*p
));
211 * Machine-dependent functions:
213 void sendsig
__P((struct proc
*, sig_t action
, int sig
,
214 int returnmask
, u_long code
));
216 #ifdef __APPLE_API_UNSTABLE
217 void psignal
__P((struct proc
*p
, int sig
));
218 void pgsignal
__P((struct pgrp
*pgrp
, int sig
, int checkctty
));
219 #endif /* __APPLE_API_UNSTABLE */
223 #endif /* __APPLE_API_PRIVATE */
225 #endif /* !_SYS_SIGNALVAR_H_ */