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