386BSD 0.1 development
[unix-history] / usr / src / sys.386bsd / sys / signal.h
CommitLineData
84322d26
WJ
1/*
2 * Copyright (c) 1982, 1986, 1989, 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 * @(#)signal.h 7.16 (Berkeley) 3/17/91
34 */
35
36#ifndef _SIGNAL_H_
37#define _SIGNAL_H_
38
39#define NSIG 32 /* counting 0; could be 33 (mask is 1-32) */
40
41#ifndef _POSIX_SOURCE
42#include <machine/trap.h> /* codes for SIGILL, SIGFPE */
43#endif /* _POSIX_SOURCE */
44
45#define SIGHUP 1 /* hangup */
46#define SIGINT 2 /* interrupt */
47#define SIGQUIT 3 /* quit */
48#define SIGILL 4 /* illegal instruction (not reset when caught) */
49#ifndef _POSIX_SOURCE
50#define SIGTRAP 5 /* trace trap (not reset when caught) */
51#endif
52#define SIGABRT 6 /* abort() */
53#ifndef _POSIX_SOURCE
54#define SIGIOT SIGABRT /* compatibility */
55#define SIGEMT 7 /* EMT instruction */
56#endif
57#define SIGFPE 8 /* floating point exception */
58#define SIGKILL 9 /* kill (cannot be caught or ignored) */
59#ifndef _POSIX_SOURCE
60#define SIGBUS 10 /* bus error */
61#endif
62#define SIGSEGV 11 /* segmentation violation */
63#ifndef _POSIX_SOURCE
64#define SIGSYS 12 /* bad argument to system call */
65#endif
66#define SIGPIPE 13 /* write on a pipe with no one to read it */
67#define SIGALRM 14 /* alarm clock */
68#define SIGTERM 15 /* software termination signal from kill */
69#ifndef _POSIX_SOURCE
70#define SIGURG 16 /* urgent condition on IO channel */
71#endif
72#define SIGSTOP 17 /* sendable stop signal not from tty */
73#define SIGTSTP 18 /* stop signal from tty */
74#define SIGCONT 19 /* continue a stopped process */
75#define SIGCHLD 20 /* to parent on child stop or exit */
76#define SIGTTIN 21 /* to readers pgrp upon background tty read */
77#define SIGTTOU 22 /* like TTIN for output if (tp->t_local&LTOSTOP) */
78#ifndef _POSIX_SOURCE
79#define SIGIO 23 /* input/output possible signal */
80#define SIGXCPU 24 /* exceeded CPU time limit */
81#define SIGXFSZ 25 /* exceeded file size limit */
82#define SIGVTALRM 26 /* virtual time alarm */
83#define SIGPROF 27 /* profiling time alarm */
84#define SIGWINCH 28 /* window size changes */
85#define SIGINFO 29 /* information request */
86#endif
87#define SIGUSR1 30 /* user defined signal 1 */
88#define SIGUSR2 31 /* user defined signal 2 */
89
90#include <sys/cdefs.h>
91
92#ifndef _POSIX_SOURCE
93typedef void (*sig_t) __P((int));
94#endif
95
96typedef void (*__sighandler_t) __P((int));
97typedef unsigned int sigset_t;
98
99__BEGIN_DECLS
100int sigaddset __P((sigset_t *, int));
101int sigdelset __P((sigset_t *, int));
102int sigemptyset __P((sigset_t *));
103int sigfillset __P((sigset_t *));
104int sigismember __P((const sigset_t *, int));
105__END_DECLS
106
107#define sigemptyset(set) ( *(set) = 0 )
108#define sigfillset(set) ( *(set) = ~(sigset_t)0, 0 )
109#define sigaddset(set, signo) ( *(set) |= 1 << ((signo) - 1), 0)
110#define sigdelset(set, signo) ( *(set) &= ~(1 << ((signo) - 1)), 0)
111#define sigismember(set, signo) ( (*(set) & (1 << ((signo) - 1))) != 0)
112
113/*
114 * Signal vector "template" used in sigaction call.
115 */
116struct sigaction {
117 __sighandler_t sa_handler; /* signal handler */
118 sigset_t sa_mask; /* signal mask to apply */
119 int sa_flags; /* see signal options below */
120};
121#ifndef _POSIX_SOURCE
122#define SA_ONSTACK 0x0001 /* take signal on signal stack */
123#define SA_RESTART 0x0002 /* do not restart system on signal return */
124#endif
125#define SA_NOCLDSTOP 0x0004 /* do not generate SIGCHLD on child stop */
126
127/*
128 * Flags for sigprocmask:
129 */
130#define SIG_BLOCK 1 /* block specified signal set */
131#define SIG_UNBLOCK 2 /* unblock specified signal set */
132#define SIG_SETMASK 3 /* set specified signal set */
133
134#ifndef _POSIX_SOURCE
135/*
136 * 4.3 compatibility:
137 * Signal vector "template" used in sigvec call.
138 */
139struct sigvec {
140 void (*sv_handler)(); /* signal handler */
141 int sv_mask; /* signal mask to apply */
142 int sv_flags; /* see signal options below */
143};
144#define SV_ONSTACK SA_ONSTACK
145#define SV_INTERRUPT SA_RESTART /* same bit, opposite sense */
146#define sv_onstack sv_flags /* isn't compatibility wonderful! */
147
148/*
149 * Structure used in sigaltstack call.
150 */
151struct sigaltstack {
152 char *ss_base; /* signal stack base */
153 int ss_len; /* signal stack length */
154 int ss_onstack; /* current status */
155};
156
157/*
158 * Structure used in sigstack call.
159 */
160struct sigstack {
161 char *ss_sp; /* signal stack pointer */
162 int ss_onstack; /* current status */
163};
164
165/*
166 * Information pushed on stack when a signal is delivered.
167 * This is used by the kernel to restore state following
168 * execution of the signal handler. It is also made available
169 * to the handler to allow it to restore state properly if
170 * a non-standard exit is performed.
171 */
172struct sigcontext {
173 int sc_onstack; /* sigstack state to restore */
174 int sc_mask; /* signal mask to restore */
175 int sc_sp; /* sp to restore */
176 int sc_fp; /* fp to restore */
177 int sc_ap; /* ap to restore */
178 int sc_pc; /* pc to restore */
179 int sc_ps; /* psl to restore */
180};
181
182/*
183 * Macro for converting signal number to a mask suitable for
184 * sigblock().
185 */
186#define sigmask(m) (1 << ((m)-1))
187
188#define BADSIG ((__sighandler_t) -1)
189#endif /* _POSIX_SOURCE */
190
191#define SIG_DFL ((__sighandler_t) 0)
192#define SIG_IGN ((__sighandler_t) 1)
193
194#ifndef KERNEL
195#include <sys/types.h>
196
197__BEGIN_DECLS
198/*void (*signal __P((int, void (*) __P((int))))) __P((int));*/
199__sighandler_t signal __P((int, __sighandler_t));
200int raise __P((int));
201#ifndef _ANSI_SOURCE
202int kill __P((pid_t, int));
203int sigaction __P((int, const struct sigaction *, struct sigaction *));
204int sigpending __P((sigset_t *));
205int sigprocmask __P((int, const sigset_t *, sigset_t *));
206int sigsuspend __P((const sigset_t *));
207#endif /* !_ANSI_SOURCE */
208#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
209int killpg __P((pid_t, int));
210void psignal __P((unsigned, const char *));
211int sigblock __P((int));
212int siginterrupt __P((int, int));
213int sigpause __P((int));
214int sigreturn __P((struct sigcontext *));
215int sigsetmask __P((int));
216int sigstack __P((const struct sigstack *, struct sigstack *));
217int sigvec __P((int, struct sigvec *, struct sigvec *));
218#endif /* !_ANSI_SOURCE && !_POSIX_SOURCE */
219__END_DECLS
220
221#endif /* !KERNEL */
222#endif /* !_SIGNAL_H_ */