xref: /original-bsd/sys/sys/signal.h (revision d4a52aff)
1 /*
2  * Copyright (c) 1982, 1986, 1989, 1991, 1993
3  *	The Regents of the University of California.  All rights reserved.
4  * (c) UNIX System Laboratories, Inc.
5  * All or some portions of this file are derived from material licensed
6  * to the University of California by American Telephone and Telegraph
7  * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8  * the permission of UNIX System Laboratories, Inc.
9  *
10  * %sccs.include.redist.c%
11  *
12  *	@(#)signal.h	8.4 (Berkeley) 05/04/95
13  */
14 
15 #ifndef	_SYS_SIGNAL_H_
16 #define	_SYS_SIGNAL_H_
17 
18 #if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
19 #define NSIG	32		/* counting 0; could be 33 (mask is 1-32) */
20 #endif
21 
22 #include <machine/signal.h>	/* sigcontext; codes for SIGILL, SIGFPE */
23 
24 #define	SIGHUP	1	/* hangup */
25 #define	SIGINT	2	/* interrupt */
26 #define	SIGQUIT	3	/* quit */
27 #define	SIGILL	4	/* illegal instruction (not reset when caught) */
28 #ifndef _POSIX_SOURCE
29 #define	SIGTRAP	5	/* trace trap (not reset when caught) */
30 #endif
31 #define	SIGABRT	6	/* abort() */
32 #ifndef _POSIX_SOURCE
33 #define	SIGIOT	SIGABRT	/* compatibility */
34 #define	SIGEMT	7	/* EMT instruction */
35 #endif
36 #define	SIGFPE	8	/* floating point exception */
37 #define	SIGKILL	9	/* kill (cannot be caught or ignored) */
38 #ifndef _POSIX_SOURCE
39 #define	SIGBUS	10	/* bus error */
40 #endif
41 #define	SIGSEGV	11	/* segmentation violation */
42 #ifndef _POSIX_SOURCE
43 #define	SIGSYS	12	/* bad argument to system call */
44 #endif
45 #define	SIGPIPE	13	/* write on a pipe with no one to read it */
46 #define	SIGALRM	14	/* alarm clock */
47 #define	SIGTERM	15	/* software termination signal from kill */
48 #ifndef _POSIX_SOURCE
49 #define	SIGURG	16	/* urgent condition on IO channel */
50 #endif
51 #define	SIGSTOP	17	/* sendable stop signal not from tty */
52 #define	SIGTSTP	18	/* stop signal from tty */
53 #define	SIGCONT	19	/* continue a stopped process */
54 #define	SIGCHLD	20	/* to parent on child stop or exit */
55 #define	SIGTTIN	21	/* to readers pgrp upon background tty read */
56 #define	SIGTTOU	22	/* like TTIN for output if (tp->t_local&LTOSTOP) */
57 #ifndef _POSIX_SOURCE
58 #define	SIGIO	23	/* input/output possible signal */
59 #define	SIGXCPU	24	/* exceeded CPU time limit */
60 #define	SIGXFSZ	25	/* exceeded file size limit */
61 #define	SIGVTALRM 26	/* virtual time alarm */
62 #define	SIGPROF	27	/* profiling time alarm */
63 #define SIGWINCH 28	/* window size changes */
64 #define SIGINFO	29	/* information request */
65 #endif
66 #define SIGUSR1 30	/* user defined signal 1 */
67 #define SIGUSR2 31	/* user defined signal 2 */
68 
69 #if defined(_ANSI_SOURCE) || defined(__cplusplus)
70 /*
71  * Language spec sez we must list exactly one parameter, even though we
72  * actually supply three.  Ugh!
73  */
74 #define	SIG_DFL		(void (*)(int))0
75 #define	SIG_IGN		(void (*)(int))1
76 #define	SIG_ERR		(void (*)(int))-1
77 #else
78 #define	SIG_DFL		(void (*)())0
79 #define	SIG_IGN		(void (*)())1
80 #define	SIG_ERR		(void (*)())-1
81 #endif
82 
83 #ifndef _ANSI_SOURCE
84 typedef unsigned int sigset_t;
85 
86 /*
87  * Signal vector "template" used in sigaction call.
88  */
89 struct	sigaction {
90 	void	(*sa_handler)(int);	/* signal handler */
91 	sigset_t sa_mask;		/* signal mask to apply */
92 	int	sa_flags;		/* see signal options below */
93 };
94 #ifndef _POSIX_SOURCE
95 #define SA_ONSTACK	0x0001	/* take signal on signal stack */
96 #define SA_RESTART	0x0002	/* restart system on signal return */
97 #define	SA_DISABLE	0x0004	/* disable taking signals on alternate stack */
98 #ifdef COMPAT_SUNOS
99 #define	SA_USERTRAMP	0x0100	/* do not bounce off kernel's sigtramp */
100 #endif
101 #endif
102 #define SA_NOCLDSTOP	0x0008	/* do not generate SIGCHLD on child stop */
103 
104 /*
105  * Flags for sigprocmask:
106  */
107 #define	SIG_BLOCK	1	/* block specified signal set */
108 #define	SIG_UNBLOCK	2	/* unblock specified signal set */
109 #define	SIG_SETMASK	3	/* set specified signal set */
110 
111 #if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
112 #ifndef KERNEL
113 #include <sys/cdefs.h>
114 #endif
115 typedef	void (*sig_t) __P((int));	/* type of signal function */
116 
117 /*
118  * Structure used in sigaltstack call.
119  */
120 struct	sigaltstack {
121 	char	*ss_base;		/* signal stack base */
122 	int	ss_size;		/* signal stack length */
123 	int	ss_flags;		/* SA_DISABLE and/or SA_ONSTACK */
124 };
125 #define	MINSIGSTKSZ	8192			/* minimum allowable stack */
126 #define	SIGSTKSZ	(MINSIGSTKSZ + 32768)	/* recommended stack size */
127 
128 /*
129  * 4.3 compatibility:
130  * Signal vector "template" used in sigvec call.
131  */
132 struct	sigvec {
133 	void	(*sv_handler)(int);	/* signal handler */
134 	int	sv_mask;		/* signal mask to apply */
135 	int	sv_flags;		/* see signal options below */
136 };
137 
138 #define SV_ONSTACK	SA_ONSTACK
139 #define SV_INTERRUPT	SA_RESTART	/* same bit, opposite sense */
140 #define sv_onstack sv_flags	/* isn't compatibility wonderful! */
141 
142 /*
143  * Structure used in sigstack call.
144  */
145 struct	sigstack {
146 	char	*ss_sp;			/* signal stack pointer */
147 	int	ss_onstack;		/* current status */
148 };
149 
150 /*
151  * Macro for converting signal number to a mask suitable for
152  * sigblock().
153  */
154 #define sigmask(m)	(1 << ((m)-1))
155 
156 #define	BADSIG		SIG_ERR
157 
158 #endif	/* !_POSIX_SOURCE */
159 #endif	/* !_ANSI_SOURCE */
160 
161 /*
162  * For historical reasons; programs expect signal's return value to be
163  * defined by <sys/signal.h>.
164  */
165 __BEGIN_DECLS
166 void	(*signal __P((int, void (*) __P((int))))) __P((int));
167 __END_DECLS
168 #endif	/* !_SYS_SIGNAL_H_ */
169