Commit | Line | Data |
---|---|---|
da7c5cc6 | 1 | /* |
15842852 | 2 | * Copyright (c) 1982, 1986, 1989 Regents of the University of California. |
d9a111c2 | 3 | * All rights reserved. |
da7c5cc6 | 4 | * |
d9a111c2 KB |
5 | * %sccs.include.redist.c% |
6 | * | |
91befe9c | 7 | * @(#)signal.h 7.15 (Berkeley) %G% |
da7c5cc6 | 8 | */ |
459fa9c4 | 9 | |
91befe9c KB |
10 | #ifndef _SIGNAL_H_ |
11 | #define _SIGNAL_H_ | |
12 | ||
7af0f94b | 13 | #define NSIG 32 /* counting 0; could be 33 (mask is 1-32) */ |
459fa9c4 | 14 | |
15842852 | 15 | #ifndef _POSIX_SOURCE |
dadba8e6 | 16 | #include <machine/trap.h> /* codes for SIGILL, SIGFPE */ |
15842852 | 17 | #endif /* _POSIX_SOURCE */ |
dadba8e6 | 18 | |
459fa9c4 SL |
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) */ | |
15842852 | 23 | #ifndef _POSIX_SOURCE |
459fa9c4 | 24 | #define SIGTRAP 5 /* trace trap (not reset when caught) */ |
15842852 MK |
25 | #endif |
26 | #define SIGABRT 6 /* abort() */ | |
27 | #ifndef _POSIX_SOURCE | |
28 | #define SIGIOT SIGABRT /* compatibility */ | |
459fa9c4 | 29 | #define SIGEMT 7 /* EMT instruction */ |
15842852 | 30 | #endif |
459fa9c4 | 31 | #define SIGFPE 8 /* floating point exception */ |
459fa9c4 | 32 | #define SIGKILL 9 /* kill (cannot be caught or ignored) */ |
15842852 | 33 | #ifndef _POSIX_SOURCE |
459fa9c4 | 34 | #define SIGBUS 10 /* bus error */ |
15842852 | 35 | #endif |
459fa9c4 | 36 | #define SIGSEGV 11 /* segmentation violation */ |
15842852 | 37 | #ifndef _POSIX_SOURCE |
459fa9c4 | 38 | #define SIGSYS 12 /* bad argument to system call */ |
15842852 | 39 | #endif |
459fa9c4 SL |
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 */ | |
15842852 | 43 | #ifndef _POSIX_SOURCE |
459fa9c4 | 44 | #define SIGURG 16 /* urgent condition on IO channel */ |
15842852 | 45 | #endif |
459fa9c4 SL |
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<OSTOP) */ | |
15842852 | 52 | #ifndef _POSIX_SOURCE |
459fa9c4 SL |
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 */ | |
a3cdc1ed | 58 | #define SIGWINCH 28 /* window size changes */ |
15842852 MK |
59 | #define SIGINFO 29 /* information request */ |
60 | #endif | |
377433a0 KM |
61 | #define SIGUSR1 30 /* user defined signal 1 */ |
62 | #define SIGUSR2 31 /* user defined signal 2 */ | |
459fa9c4 | 63 | |
15842852 MK |
64 | #ifndef _POSIX_SOURCE |
65 | typedef void (*sig_t)(); | |
d9a111c2 KB |
66 | #endif |
67 | ||
459fa9c4 | 68 | #ifndef KERNEL |
15842852 | 69 | void (*signal())(); |
d9a111c2 | 70 | #endif |
15842852 | 71 | |
7af0f94b | 72 | typedef unsigned int sigset_t; |
15842852 | 73 | |
91befe9c KB |
74 | #include <sys/cdefs.h> |
75 | ||
76 | __BEGIN_DECLS | |
77 | int sigaddset __P((sigset_t *, int)); | |
78 | int sigdelset __P((sigset_t *, int)); | |
79 | int sigemptyset __P((sigset_t *)); | |
80 | int sigfillset __P((sigset_t *)); | |
81 | int sigismember __P((const sigset_t *, int)); | |
82 | __END_DECLS | |
d9a111c2 | 83 | |
7af0f94b | 84 | #define sigemptyset(set) ( *(set) = 0 ) |
bd50c095 | 85 | #define sigfillset(set) ( *(set) = ~(sigset_t)0, 0 ) |
15842852 MK |
86 | #define sigaddset(set, signo) ( *(set) |= 1 << ((signo) - 1), 0) |
87 | #define sigdelset(set, signo) ( *(set) &= ~(1 << ((signo) - 1)), 0) | |
88 | #define sigismember(set, signo) ( (*(set) & (1 << ((signo) - 1))) != 0) | |
459fa9c4 | 89 | |
457aa395 | 90 | /* |
15842852 MK |
91 | * Signal vector "template" used in sigaction call. |
92 | */ | |
93 | struct sigaction { | |
94 | void (*sa_handler)(); /* signal handler */ | |
95 | sigset_t sa_mask; /* signal mask to apply */ | |
96 | int sa_flags; /* see signal options below */ | |
97 | }; | |
98 | #ifndef _POSIX_SOURCE | |
99 | #define SA_ONSTACK 0x0001 /* take signal on signal stack */ | |
100 | #define SA_RESTART 0x0002 /* do not restart system on signal return */ | |
d9a111c2 | 101 | #endif |
15842852 MK |
102 | #define SA_NOCLDSTOP 0x0004 /* 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 | #ifndef _POSIX_SOURCE | |
112 | /* | |
113 | * 4.3 compatibility: | |
457aa395 SL |
114 | * Signal vector "template" used in sigvec call. |
115 | */ | |
116 | struct sigvec { | |
15842852 | 117 | void (*sv_handler)(); /* signal handler */ |
457aa395 | 118 | int sv_mask; /* signal mask to apply */ |
94b103e7 | 119 | int sv_flags; /* see signal options below */ |
457aa395 | 120 | }; |
15842852 MK |
121 | #define SV_ONSTACK SA_ONSTACK |
122 | #define SV_INTERRUPT SA_RESTART /* same bit, opposite sense */ | |
94b103e7 | 123 | #define sv_onstack sv_flags /* isn't compatibility wonderful! */ |
457aa395 SL |
124 | |
125 | /* | |
126 | * Structure used in sigstack call. | |
127 | */ | |
128 | struct sigstack { | |
129 | char *ss_sp; /* signal stack pointer */ | |
130 | int ss_onstack; /* current status */ | |
131 | }; | |
132 | ||
459fa9c4 SL |
133 | /* |
134 | * Information pushed on stack when a signal is delivered. | |
135 | * This is used by the kernel to restore state following | |
136 | * execution of the signal handler. It is also made available | |
15842852 | 137 | * to the handler to allow it to restore state properly if |
459fa9c4 SL |
138 | * a non-standard exit is performed. |
139 | */ | |
140 | struct sigcontext { | |
141 | int sc_onstack; /* sigstack state to restore */ | |
142 | int sc_mask; /* signal mask to restore */ | |
85e59a99 | 143 | int sc_sp; /* sp to restore */ |
1a4db9fc MK |
144 | int sc_fp; /* fp to restore */ |
145 | int sc_ap; /* ap to restore */ | |
146 | int sc_pc; /* pc to restore */ | |
459fa9c4 SL |
147 | int sc_ps; /* psl to restore */ |
148 | }; | |
149 | ||
c3d189b3 RC |
150 | /* |
151 | * Macro for converting signal number to a mask suitable for | |
152 | * sigblock(). | |
153 | */ | |
154 | #define sigmask(m) (1 << ((m)-1)) | |
15842852 MK |
155 | |
156 | #define BADSIG (void (*)())-1 | |
157 | #endif /* _POSIX_SOURCE */ | |
158 | ||
159 | #define SIG_DFL (void (*)())0 | |
160 | #define SIG_IGN (void (*)())1 | |
161 | ||
162 | #ifdef KERNEL | |
163 | #define SIG_CATCH (void (*)())2 | |
164 | #define SIG_HOLD (void (*)())3 | |
7af0f94b MK |
165 | |
166 | #define sigcantmask (sigmask(SIGKILL)|sigmask(SIGSTOP)) | |
167 | /* | |
168 | * get signal action for process and signal; currently only for current process | |
169 | */ | |
170 | #define SIGACTION(p, sig) (u.u_signal[(sig)]) | |
fb975b1a MK |
171 | |
172 | /* | |
173 | * Determine signal that should be delivered to process p, the current process, | |
174 | * 0 if none. If there is a pending stop signal with default action, | |
175 | * the process stops in issig(). | |
176 | */ | |
177 | #define CURSIG(p) \ | |
178 | (((p)->p_sig == 0 || \ | |
179 | ((p)->p_flag&STRC) == 0 && ((p)->p_sig &~ (p)->p_sigmask) == 0) ? \ | |
180 | 0 : issig()) | |
181 | ||
0b9e24ec MK |
182 | /* |
183 | * Clear a pending signal from a process. | |
184 | */ | |
185 | #define CLRSIG(p, sig) { (p)->p_sig &= ~sigmask(sig); } | |
186 | ||
d9a111c2 KB |
187 | #endif /* KERNEL */ |
188 | ||
0f9e0ffb | 189 | #ifndef KERNEL |
60b1a307 | 190 | #include <sys/types.h> |
91befe9c KB |
191 | |
192 | __BEGIN_DECLS | |
193 | int kill __P((pid_t, int)); | |
194 | int sigaction __P((int, const struct sigaction *, struct sigaction *)); | |
195 | int sigpending __P((sigset_t *)); | |
196 | int sigprocmask __P((int, const sigset_t *, sigset_t *)); | |
197 | int sigsuspend __P((const sigset_t *)); | |
198 | __END_DECLS | |
0f9e0ffb | 199 | #endif |
91befe9c | 200 | #endif /* !_SIGNAL_H_ */ |