386BSD 0.1 development
[unix-history] / usr / src / sys.386bsd / sys / signalvar.h
CommitLineData
b688fc87
WJ
1/*
2 * Copyright (c) 1991 Regents of the University of California.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * @(#)signalvar.h 7.1 (Berkeley) 5/9/91
34 */
35
36#ifndef _SIGNALVAR_H_ /* tmp for user.h */
37#define _SIGNALVAR_H_
38
39/*
40 * Kernel signal definitions and data structures,
41 * not exported to user programs.
42 */
43
44/*
45 * Process signal actions and state, needed only within the process
46 * (not necessarily resident).
47 */
48struct sigacts {
49 sig_t ps_sigact[NSIG]; /* disposition of signals */
50 sigset_t ps_catchmask[NSIG]; /* signals to be blocked */
51 sigset_t ps_sigonstack; /* signals to take on sigstack */
52 sigset_t ps_sigintr; /* signals that interrupt syscalls */
53 sigset_t ps_oldmask; /* saved mask from before sigpause */
54 int ps_flags; /* signal flags, below */
55 struct sigstack ps_sigstack; /* sp & on stack state variable */
56 int ps_sig; /* for core dump/debugger XXX */
57 int ps_code; /* for core dump/debugger XXX */
58};
59
60#define ps_onstack ps_sigstack.ss_onstack
61#define ps_sigsp ps_sigstack.ss_sp
62
63/* signal flags */
64#define SA_OLDMASK 0x01 /* need to restore mask before pause */
65
66/* additional signal action values, used only temporarily/internally */
67#define SIG_CATCH (void (*)())2
68#define SIG_HOLD (void (*)())3
69
70/*
71 * get signal action for process and signal; currently only for current process
72 */
73#define SIGACTION(p, sig) (p->p_sigacts->ps_sigact[(sig)])
74
75/*
76 * Determine signal that should be delivered to process p, the current process,
77 * 0 if none. If there is a pending stop signal with default action,
78 * the process stops in issig().
79 */
80#define CURSIG(p) \
81 (((p)->p_sig == 0 || \
82 ((p)->p_flag&STRC) == 0 && ((p)->p_sig &~ (p)->p_sigmask) == 0) ? \
83 0 : issig(p))
84
85/*
86 * Clear a pending signal from a process.
87 */
88#define CLRSIG(p, sig) { (p)->p_sig &= ~sigmask(sig); }
89
90/*
91 * Signal properties and actions.
92 * The array below categorizes the signals and their default actions
93 * according to the following properties:
94 */
95#define SA_KILL 0x01 /* terminates process by default */
96#define SA_CORE 0x02 /* ditto and coredumps */
97#define SA_STOP 0x04 /* suspend process */
98#define SA_TTYSTOP (0x08|SA_STOP) /* ditto, from tty */
99#define SA_IGNORE 0x10 /* ignore by default */
100#define SA_CONT 0x20 /* continue if suspended */
101#define SA_CANTMASK 0x40 /* non-maskable, catchable */
102
103#ifdef SIGPROP
104int sigprop[NSIG + 1] = {
105 0, /* unused */
106 SA_KILL, /* SIGHUP */
107 SA_KILL, /* SIGINT */
108 SA_KILL|SA_CORE, /* SIGQUIT */
109 SA_KILL|SA_CORE, /* SIGILL */
110 SA_KILL|SA_CORE, /* SIGTRAP */
111 SA_KILL|SA_CORE, /* SIGABRT */
112 SA_KILL|SA_CORE, /* SIGEMT */
113 SA_KILL|SA_CORE, /* SIGFPE */
114 SA_KILL, /* SIGKILL */
115 SA_KILL|SA_CORE, /* SIGBUS */
116 SA_KILL|SA_CORE, /* SIGSEGV */
117 SA_KILL|SA_CORE, /* SIGSYS */
118 SA_KILL, /* SIGPIPE */
119 SA_KILL, /* SIGALRM */
120 SA_KILL, /* SIGTERM */
121 SA_IGNORE, /* SIGURG */
122 SA_STOP, /* SIGSTOP */
123 SA_TTYSTOP, /* SIGTSTP */
124 SA_IGNORE|SA_CONT, /* SIGCONT */
125 SA_IGNORE, /* SIGCHLD */
126 SA_TTYSTOP, /* SIGTTIN */
127 SA_TTYSTOP, /* SIGTTOU */
128 SA_IGNORE, /* SIGIO */
129 SA_KILL, /* SIGXCPU */
130 SA_KILL, /* SIGXFSZ */
131 SA_KILL, /* SIGVTALRM */
132 SA_KILL, /* SIGPROF */
133 SA_IGNORE, /* SIGWINCH */
134 SA_IGNORE, /* SIGINFO */
135 SA_KILL, /* SIGUSR1 */
136 SA_KILL, /* SIGUSR2 */
137};
138
139#define stopsigmask (sigmask(SIGSTOP)|sigmask(SIGTSTP)|\
140 sigmask(SIGTTIN)|sigmask(SIGTTOU))
141#define contsigmask (sigmask(SIGCONT))
142
143#endif /* SIGPROP */
144
145#define sigcantmask (sigmask(SIGKILL)|sigmask(SIGSTOP))
146
147#ifdef KERNEL
148/*
149 * Machine-independent functions:
150 */
151void siginit __P((struct proc *p));
152void execsigs __P((struct proc *p));
153void gsignal __P((int pgid, int sig));
154void pgsignal __P((struct pgrp *pgrp, int sig, int checkctty));
155void trapsignal __P((struct proc *p, int sig, unsigned code));
156void psignal __P((struct proc *p, int sig));
157int issig __P((struct proc *p));
158void psig __P((int sig));
159int coredump __P((struct proc *p));
160
161/*
162 * Machine-dependent functions:
163 */
164void sendsig __P((sig_t action, int sig, int returnmask, unsigned code));
165#endif /* KERNEL */
166#endif /* !_SIGNALVAR_H_ */