]>
git.saurik.com Git - apple/xnu.git/blob - bsd/sys/signalvar.h
68199f53e6a0f35b521d9a4289c485a8d79ead77
2 * Copyright (c) 2000-2002 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) 1991, 1993
25 * The Regents of the University of California. All rights reserved.
27 * Redistribution and use in source and binary forms, with or without
28 * modification, are permitted provided that the following conditions
30 * 1. Redistributions of source code must retain the above copyright
31 * notice, this list of conditions and the following disclaimer.
32 * 2. Redistributions in binary form must reproduce the above copyright
33 * notice, this list of conditions and the following disclaimer in the
34 * documentation and/or other materials provided with the distribution.
35 * 3. All advertising materials mentioning features or use of this software
36 * must display the following acknowledgement:
37 * This product includes software developed by the University of
38 * California, Berkeley and its contributors.
39 * 4. Neither the name of the University nor the names of its contributors
40 * may be used to endorse or promote products derived from this software
41 * without specific prior written permission.
43 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
44 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
45 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
46 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
47 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
48 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
49 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
50 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
51 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
52 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
55 * @(#)signalvar.h 8.3 (Berkeley) 1/4/94
58 #ifndef _SYS_SIGNALVAR_H_ /* tmp for user.h */
59 #define _SYS_SIGNALVAR_H_
61 #include <sys/appleapiopts.h>
63 #ifdef __APPLE_API_PRIVATE
65 * Kernel signal definitions and data structures,
66 * not exported to user programs.
70 * Process signal actions and state, needed only within the process
71 * (not necessarily resident).
74 sig_t ps_sigact
[NSIG
]; /* disposition of signals */
75 sig_t ps_trampact
[NSIG
]; /* disposition of signals */
76 sigset_t ps_catchmask
[NSIG
]; /* signals to be blocked */
77 sigset_t ps_sigonstack
; /* signals to take on sigstack */
78 sigset_t ps_sigintr
; /* signals that interrupt syscalls */
79 sigset_t ps_sigreset
; /* signals that reset when caught */
80 sigset_t ps_signodefer
; /* signals not masked while handled */
81 sigset_t ps_siginfo
; /* signals that want SA_SIGINFO args */
82 sigset_t ps_oldmask
; /* saved mask from before sigpause */
83 int ps_flags
; /* signal flags, below */
84 struct sigaltstack ps_sigstk
; /* sp & on stack state variable */
85 int ps_sig
; /* for core dump/debugger XXX */
86 int ps_code
; /* for core dump/debugger XXX */
87 int ps_addr
; /* for core dump/debugger XXX */
88 sigset_t ps_usertramp
; /* SunOS compat; libc sigtramp XXX */
92 #define SAS_OLDMASK 0x01 /* need to restore mask before pause */
93 #define SAS_ALTSTACK 0x02 /* have alternate signal stack */
95 /* additional signal action values, used only temporarily/internally */
96 #define SIG_CATCH (void (*)())2
97 #define SIG_HOLD (void (*)())3
98 #define SIG_WAIT (void (*)())4
100 #define pgsigio(pgid, sig, notused) \
104 gsignal(-(pgid), sig);\
105 else if (pgid > 0 && (p = pfind(pgid)) != 0) \
110 * get signal action for process and signal; currently only for current process
112 #define SIGACTION(p, sig) (p->p_sigacts->ps_sigact[(sig)])
115 * Check for per-process and per thread signals.
117 #define SHOULDissignal(p,uthreadp) \
118 (((uthreadp)->uu_siglist) \
119 & ~((((uthreadp)->uu_sigmask) \
120 | (((p)->p_flag & P_TRACED) ? 0 : (p)->p_sigignore)) \
124 * Check for signals and per-thread signals.
125 * Use in trap() and syscall() before
128 #define CHECK_SIGNALS(p, thread, uthreadp) \
129 (!thread_should_halt(thread) \
130 && (SHOULDissignal(p,uthreadp)))
133 * Signal properties and actions.
134 * The array below categorizes the signals and their default actions
135 * according to the following properties:
137 #define SA_KILL 0x01 /* terminates process by default */
138 #define SA_CORE 0x02 /* ditto and coredumps */
139 #define SA_STOP 0x04 /* suspend process */
140 #define SA_TTYSTOP 0x08 /* ditto, from tty */
141 #define SA_IGNORE 0x10 /* ignore by default */
142 #define SA_CONT 0x20 /* continue if suspended */
143 #define SA_CANTMASK 0x40 /* non-maskable, catchable */
146 int sigprop
[NSIG
+ 1] = {
148 SA_KILL
, /* SIGHUP */
149 SA_KILL
, /* SIGINT */
150 SA_KILL
|SA_CORE
, /* SIGQUIT */
151 SA_KILL
|SA_CORE
, /* SIGILL */
152 SA_KILL
|SA_CORE
, /* SIGTRAP */
153 SA_KILL
|SA_CORE
, /* SIGABRT */
154 SA_KILL
|SA_CORE
, /* SIGEMT */
155 SA_KILL
|SA_CORE
, /* SIGFPE */
156 SA_KILL
, /* SIGKILL */
157 SA_KILL
|SA_CORE
, /* SIGBUS */
158 SA_KILL
|SA_CORE
, /* SIGSEGV */
159 SA_KILL
|SA_CORE
, /* SIGSYS */
160 SA_KILL
, /* SIGPIPE */
161 SA_KILL
, /* SIGALRM */
162 SA_KILL
, /* SIGTERM */
163 SA_IGNORE
, /* SIGURG */
164 SA_STOP
, /* SIGSTOP */
165 SA_STOP
|SA_TTYSTOP
, /* SIGTSTP */
166 SA_IGNORE
|SA_CONT
, /* SIGCONT */
167 SA_IGNORE
, /* SIGCHLD */
168 SA_STOP
|SA_TTYSTOP
, /* SIGTTIN */
169 SA_STOP
|SA_TTYSTOP
, /* SIGTTOU */
170 SA_IGNORE
, /* SIGIO */
171 SA_KILL
, /* SIGXCPU */
172 SA_KILL
, /* SIGXFSZ */
173 SA_KILL
, /* SIGVTALRM */
174 SA_KILL
, /* SIGPROF */
175 SA_IGNORE
, /* SIGWINCH */
176 SA_IGNORE
, /* SIGINFO */
177 SA_KILL
, /* SIGUSR1 */
178 SA_KILL
, /* SIGUSR2 */
181 #define contsigmask (sigmask(SIGCONT))
182 #define stopsigmask (sigmask(SIGSTOP) | sigmask(SIGTSTP) | \
183 sigmask(SIGTTIN) | sigmask(SIGTTOU))
187 #define sigcantmask (sigmask(SIGKILL) | sigmask(SIGSTOP))
191 * Machine-independent functions:
193 int coredump
__P((struct proc
*p
));
194 void execsigs
__P((struct proc
*p
, thread_act_t thr_act
));
195 void gsignal
__P((int pgid
, int sig
));
196 int issignal
__P((struct proc
*p
));
197 int CURSIG
__P((struct proc
*p
));
198 int clear_procsiglist
__P((struct proc
*p
, int bit
));
199 int clear_procsigmask
__P((struct proc
*p
, int bit
));
200 int set_procsigmask
__P((struct proc
*p
, int bit
));
201 void tty_pgsignal
__P((struct pgrp
*pgrp
, int sig
));
202 void postsig
__P((int sig
));
203 void siginit
__P((struct proc
*p
));
204 void trapsignal
__P((struct proc
*p
, int sig
, unsigned code
));
205 void pt_setrunnable
__P((struct proc
*p
));
208 * Machine-dependent functions:
210 void sendsig
__P((struct proc
*, sig_t action
, int sig
,
211 int returnmask
, u_long code
));
213 #ifdef __APPLE_API_UNSTABLE
214 void psignal
__P((struct proc
*p
, int sig
));
215 void pgsignal
__P((struct pgrp
*pgrp
, int sig
, int checkctty
));
216 #endif /* __APPLE_API_UNSTABLE */
220 #endif /* __APPLE_API_PRIVATE */
222 #endif /* !_SYS_SIGNALVAR_H_ */