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