2 * Copyright (c) 2006 Apple Computer, Inc. All Rights Reserved.
4 * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
30 /* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */
32 * Copyright (c) 1991, 1993
33 * The Regents of the University of California. All rights reserved.
35 * Redistribution and use in source and binary forms, with or without
36 * modification, are permitted provided that the following conditions
38 * 1. Redistributions of source code must retain the above copyright
39 * notice, this list of conditions and the following disclaimer.
40 * 2. Redistributions in binary form must reproduce the above copyright
41 * notice, this list of conditions and the following disclaimer in the
42 * documentation and/or other materials provided with the distribution.
43 * 3. All advertising materials mentioning features or use of this software
44 * must display the following acknowledgement:
45 * This product includes software developed by the University of
46 * California, Berkeley and its contributors.
47 * 4. Neither the name of the University nor the names of its contributors
48 * may be used to endorse or promote products derived from this software
49 * without specific prior written permission.
51 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
52 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
53 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
54 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
55 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
56 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
57 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
58 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
59 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
60 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
63 * @(#)signalvar.h 8.3 (Berkeley) 1/4/94
66 #ifndef _SYS_SIGNALVAR_H_ /* tmp for user.h */
67 #define _SYS_SIGNALVAR_H_
69 #include <sys/appleapiopts.h>
71 #ifdef BSD_KERNEL_PRIVATE
73 * Kernel signal definitions and data structures,
74 * not exported to user programs.
78 * Process signal actions and state, needed only within the process
79 * (not necessarily resident).
82 user_addr_t ps_sigact
[NSIG
]; /* disposition of signals */
83 user_addr_t ps_trampact
[NSIG
]; /* disposition of signals */
84 sigset_t ps_catchmask
[NSIG
]; /* signals to be blocked */
85 sigset_t ps_sigonstack
; /* signals to take on sigstack */
86 sigset_t ps_sigintr
; /* signals that interrupt syscalls */
87 sigset_t ps_sigreset
; /* signals that reset when caught */
88 sigset_t ps_signodefer
; /* signals not masked while handled */
89 sigset_t ps_siginfo
; /* signals that want SA_SIGINFO args */
90 sigset_t ps_oldmask
; /* saved mask from before sigpause */
91 int ps_flags
; /* signal flags, below */
92 struct user_sigaltstack ps_sigstk
; /* sp, length & flags */
93 int ps_sig
; /* for core dump/debugger XXX */
94 int ps_code
; /* for core dump/debugger XXX */
95 int ps_addr
; /* for core dump/debugger XXX */
96 sigset_t ps_usertramp
; /* SunOS compat; libc sigtramp XXX */
97 sigset_t ps_64regset
; /* signals that want SA_EXSIGINFO args */
101 #define SAS_OLDMASK 0x01 /* need to restore mask before pause */
102 #define SAS_ALTSTACK 0x02 /* have alternate signal stack */
105 * Additional signal action values, used only temporarily/internally; these
106 * values should be non-intersecting with values defined in signal.h, e.g.:
107 * SIG_IGN, SIG_DFL, SIG_ERR, SIG_IGN.
109 #define KERN_SIG_CATCH (void (*)(int))2
110 #define KERN_SIG_HOLD (void (*)(int))3
111 #define KERN_SIG_WAIT (void (*)(int))4
113 #define pgsigio(pgid, sig, notused) \
117 gsignal(-(pgid), sig);\
118 else if (pgid > 0 && (p = pfind(pgid)) != 0) \
123 * get signal action for process and signal; currently only for current process
125 #define SIGACTION(p, sig) (p->p_sigacts->ps_sigact[(sig)])
128 * Check for per-process and per thread signals.
130 #define SHOULDissignal(p,uthreadp) \
131 (((uthreadp)->uu_siglist) \
132 & ~((((uthreadp)->uu_sigmask) \
133 | (((p)->p_flag & P_TRACED) ? 0 : (p)->p_sigignore)) \
137 * Check for signals and per-thread signals.
138 * Use in trap() and syscall() before
141 #define CHECK_SIGNALS(p, thread, uthreadp) \
142 (!thread_should_halt(thread) \
143 && (SHOULDissignal(p,uthreadp)))
146 * Signal properties and actions.
147 * The array below categorizes the signals and their default actions
148 * according to the following properties:
150 #define SA_KILL 0x01 /* terminates process by default */
151 #define SA_CORE 0x02 /* ditto and coredumps */
152 #define SA_STOP 0x04 /* suspend process */
153 #define SA_TTYSTOP 0x08 /* ditto, from tty */
154 #define SA_IGNORE 0x10 /* ignore by default */
155 #define SA_CONT 0x20 /* continue if suspended */
156 #define SA_CANTMASK 0x40 /* non-maskable, catchable */
159 int sigprop
[NSIG
+ 1] = {
161 SA_KILL
, /* SIGHUP */
162 SA_KILL
, /* SIGINT */
163 SA_KILL
|SA_CORE
, /* SIGQUIT */
164 SA_KILL
|SA_CORE
, /* SIGILL */
165 SA_KILL
|SA_CORE
, /* SIGTRAP */
166 SA_KILL
|SA_CORE
, /* SIGABRT */
167 SA_KILL
|SA_CORE
, /* SIGEMT */
168 SA_KILL
|SA_CORE
, /* SIGFPE */
169 SA_KILL
, /* SIGKILL */
170 SA_KILL
|SA_CORE
, /* SIGBUS */
171 SA_KILL
|SA_CORE
, /* SIGSEGV */
172 SA_KILL
|SA_CORE
, /* SIGSYS */
173 SA_KILL
, /* SIGPIPE */
174 SA_KILL
, /* SIGALRM */
175 SA_KILL
, /* SIGTERM */
176 SA_IGNORE
, /* SIGURG */
177 SA_STOP
, /* SIGSTOP */
178 SA_STOP
|SA_TTYSTOP
, /* SIGTSTP */
179 SA_IGNORE
|SA_CONT
, /* SIGCONT */
180 SA_IGNORE
, /* SIGCHLD */
181 SA_STOP
|SA_TTYSTOP
, /* SIGTTIN */
182 SA_STOP
|SA_TTYSTOP
, /* SIGTTOU */
183 SA_IGNORE
, /* SIGIO */
184 SA_KILL
, /* SIGXCPU */
185 SA_KILL
, /* SIGXFSZ */
186 SA_KILL
, /* SIGVTALRM */
187 SA_KILL
, /* SIGPROF */
188 SA_IGNORE
, /* SIGWINCH */
189 SA_IGNORE
, /* SIGINFO */
190 SA_KILL
, /* SIGUSR1 */
191 SA_KILL
, /* SIGUSR2 */
194 #define contsigmask (sigmask(SIGCONT))
195 #define stopsigmask (sigmask(SIGSTOP) | sigmask(SIGTSTP) | \
196 sigmask(SIGTTIN) | sigmask(SIGTTOU))
200 #define sigcantmask (sigmask(SIGKILL) | sigmask(SIGSTOP))
203 * Machine-independent functions:
205 int signal_lock(struct proc
*);
206 int signal_unlock(struct proc
*);
207 int coredump(struct proc
*p
);
208 void execsigs(struct proc
*p
, thread_t thread
);
209 void gsignal(int pgid
, int sig
);
210 int issignal(struct proc
*p
);
211 int CURSIG(struct proc
*p
);
212 int clear_procsiglist(struct proc
*p
, int bit
);
213 int clear_procsigmask(struct proc
*p
, int bit
);
214 int set_procsigmask(struct proc
*p
, int bit
);
215 void tty_pgsignal(struct pgrp
*pgrp
, int sig
);
216 void postsig(int sig
);
217 void siginit(struct proc
*p
);
218 void trapsignal(struct proc
*p
, int sig
, unsigned code
);
219 void pt_setrunnable(struct proc
*p
);
222 * Machine-dependent functions:
224 void sendsig(struct proc
*, /*sig_t*/ user_addr_t action
, int sig
,
225 int returnmask
, u_long code
);
227 void psignal(struct proc
*p
, int sig
);
228 void pgsignal(struct pgrp
*pgrp
, int sig
, int checkctty
);
229 void threadsignal(thread_t sig_actthread
, int signum
, u_long code
);
230 int thread_issignal(proc_t p
, thread_t th
, sigset_t mask
);
231 void psignal_vfork(struct proc
*p
, task_t new_task
, thread_t thr_act
,
233 void psignal_vtalarm(struct proc
*);
234 void psignal_xcpu(struct proc
*);
235 void psignal_sigprof(struct proc
*);
236 void psignal_lock(struct proc
*, int, int);
237 void signal_setast(thread_t sig_actthread
);
239 /* XXX not really very "inline"... */
240 __inline__
void sig_lock_to_exit(struct proc
*p
);
241 __inline__
int sig_try_locked(struct proc
*p
);
243 #endif /* BSD_KERNEL_PRIVATE */
245 #endif /* !_SYS_SIGNALVAR_H_ */