xref: /original-bsd/sys/sys/signal.h (revision bdc0a208)
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.16 (Berkeley) 03/17/91
8  */
9 
10 #ifndef	_SIGNAL_H_
11 #define	_SIGNAL_H_
12 
13 #define NSIG	32		/* counting 0; could be 33 (mask is 1-32) */
14 
15 #ifndef _POSIX_SOURCE
16 #include <machine/trap.h>	/* codes for SIGILL, SIGFPE */
17 #endif /* _POSIX_SOURCE */
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 #include <sys/cdefs.h>
65 
66 #ifndef _POSIX_SOURCE
67 typedef	void (*sig_t) __P((int));
68 #endif
69 
70 typedef unsigned int sigset_t;
71 
72 __BEGIN_DECLS
73 int	sigaddset __P((sigset_t *, int));
74 int	sigdelset __P((sigset_t *, int));
75 int	sigemptyset __P((sigset_t *));
76 int	sigfillset __P((sigset_t *));
77 int	sigismember __P((const sigset_t *, int));
78 __END_DECLS
79 
80 #define sigemptyset(set)	( *(set) = 0 )
81 #define sigfillset(set)		( *(set) = ~(sigset_t)0, 0 )
82 #define sigaddset(set, signo)	( *(set) |= 1 << ((signo) - 1), 0)
83 #define sigdelset(set, signo)	( *(set) &= ~(1 << ((signo) - 1)), 0)
84 #define sigismember(set, signo)	( (*(set) & (1 << ((signo) - 1))) != 0)
85 
86 /*
87  * Signal vector "template" used in sigaction call.
88  */
89 struct	sigaction {
90 	void	(*sa_handler)();	/* 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	/* do not restart system on signal return */
97 #endif
98 #define SA_NOCLDSTOP	0x0004	/* do not generate SIGCHLD on child stop */
99 
100 /*
101  * Flags for sigprocmask:
102  */
103 #define	SIG_BLOCK	1	/* block specified signal set */
104 #define	SIG_UNBLOCK	2	/* unblock specified signal set */
105 #define	SIG_SETMASK	3	/* set specified signal set */
106 
107 #ifndef _POSIX_SOURCE
108 /*
109  * 4.3 compatibility:
110  * Signal vector "template" used in sigvec call.
111  */
112 struct	sigvec {
113 	void	(*sv_handler)();	/* signal handler */
114 	int	sv_mask;		/* signal mask to apply */
115 	int	sv_flags;		/* see signal options below */
116 };
117 #define SV_ONSTACK	SA_ONSTACK
118 #define SV_INTERRUPT	SA_RESTART	/* same bit, opposite sense */
119 #define sv_onstack sv_flags	/* isn't compatibility wonderful! */
120 
121 /*
122  * Structure used in sigaltstack call.
123  */
124 struct	sigaltstack {
125 	char	*ss_base;		/* signal stack base */
126 	int	ss_len;			/* signal stack length */
127 	int	ss_onstack;		/* current status */
128 };
129 
130 /*
131  * Structure used in sigstack call.
132  */
133 struct	sigstack {
134 	char	*ss_sp;			/* signal stack pointer */
135 	int	ss_onstack;		/* current status */
136 };
137 
138 /*
139  * Information pushed on stack when a signal is delivered.
140  * This is used by the kernel to restore state following
141  * execution of the signal handler.  It is also made available
142  * to the handler to allow it to restore state properly if
143  * a non-standard exit is performed.
144  */
145 struct	sigcontext {
146 	int	sc_onstack;		/* sigstack state to restore */
147 	int	sc_mask;		/* signal mask to restore */
148 	int	sc_sp;			/* sp to restore */
149 	int	sc_fp;			/* fp to restore */
150 	int	sc_ap;			/* ap to restore */
151 	int	sc_pc;			/* pc to restore */
152 	int	sc_ps;			/* psl to restore */
153 };
154 
155 /*
156  * Macro for converting signal number to a mask suitable for
157  * sigblock().
158  */
159 #define sigmask(m)	(1 << ((m)-1))
160 
161 #define	BADSIG		(void (*)())-1
162 #endif	/* _POSIX_SOURCE */
163 
164 #define	SIG_DFL		(void (*)())0
165 #define	SIG_IGN		(void (*)())1
166 
167 #ifndef KERNEL
168 #include <sys/types.h>
169 
170 __BEGIN_DECLS
171 void	(*signal __P((int, void (*) __P((int))))) __P((int));
172 int	raise __P((int));
173 #ifndef	_ANSI_SOURCE
174 int	kill __P((pid_t, int));
175 int	sigaction __P((int, const struct sigaction *, struct sigaction *));
176 int	sigpending __P((sigset_t *));
177 int	sigprocmask __P((int, const sigset_t *, sigset_t *));
178 int	sigsuspend __P((const sigset_t *));
179 #endif	/* !_ANSI_SOURCE */
180 #if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
181 int	killpg __P((pid_t, int));
182 void	psignal __P((unsigned, const char *));
183 int	sigblock __P((int));
184 int	siginterrupt __P((int, int));
185 int	sigpause __P((int));
186 int	sigreturn __P((struct sigcontext *));
187 int	sigsetmask __P((int));
188 int	sigstack __P((const struct sigstack *, struct sigstack *));
189 int	sigvec __P((int, struct sigvec *, struct sigvec *));
190 #endif /* !_ANSI_SOURCE && !_POSIX_SOURCE */
191 __END_DECLS
192 
193 #endif	/* !KERNEL */
194 #endif	/* !_SIGNAL_H_ */
195