]> git.ipfire.org Git - thirdparty/glibc.git/blob - signal/signal.h
Update.
[thirdparty/glibc.git] / signal / signal.h
1 /* Copyright (C) 1991, 92, 93, 94, 95, 96, 97 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public
15 License along with the GNU C Library; see the file COPYING.LIB. If not,
16 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. */
18
19 /*
20 * ISO C Standard: 4.7 SIGNAL HANDLING <signal.h>
21 */
22
23 #ifndef _SIGNAL_H
24
25 #if !defined __need_sig_atomic_t && !defined __need_sigset_t
26 #define _SIGNAL_H 1
27 #include <features.h>
28 #endif
29
30 __BEGIN_DECLS
31
32 #include <bits/types.h>
33 #include <bits/sigset.h> /* __sigset_t, __sig_atomic_t. */
34
35 #if !defined __sig_atomic_t_defined \
36 && (defined _SIGNAL_H || defined __need_sig_atomic_t)
37 /* An integral type that can be modified atomically, without the
38 possibility of a signal arriving in the middle of the operation. */
39 typedef __sig_atomic_t sig_atomic_t;
40 #endif /* `sig_atomic_t' undefined and <signal.h> or need `sig_atomic_t'. */
41 #undef __need_sig_atomic_t
42
43 #ifdef _SIGNAL_H
44
45 #include <bits/signum.h>
46
47 /* Type of a signal handler. */
48 typedef void (*__sighandler_t) __P ((int));
49
50 /* Set the handler for the signal SIG to HANDLER, returning the old
51 handler, or SIG_ERR on error.
52 By default `signal' has the BSD semantic. */
53 extern __sighandler_t signal __P ((int __sig, __sighandler_t __handler));
54
55 /* The X/Open definition of `signal' specifies the SVID semantic. Use
56 the additional function `sysv_signal' when X/Open compatibility is
57 requested. */
58 extern __sighandler_t __sysv_signal __P ((int __sig,
59 __sighandler_t __handler));
60
61 #if defined __USE_XOPEN && !defined __USE_GNU
62 extern __sighandler_t sysv_signal __P ((int __sig, __sighandler_t __handler));
63
64 /* Make sure the used `signal' implementation is the SVID version. */
65 #define signal(sig, handler) __sysv_signal ((sig), (handler))
66 #endif
67
68 #ifdef __USE_XOPEN
69 /* The X/Open definition of `signal' conflicts with the BSD version.
70 So they defined another function `bsd_signal'. */
71 extern __sighandler_t __bsd_signal __P ((int __sig, __sighandler_t __handler));
72 extern __sighandler_t bsd_signal __P ((int __sig, __sighandler_t __handler));
73 #endif
74
75 /* Send signal SIG to process number PID. If PID is zero,
76 send SIG to all processes in the current process's process group.
77 If PID is < -1, send SIG to all processes in process group - PID. */
78 extern int __kill __P ((__pid_t __pid, int __sig));
79 #ifdef __USE_POSIX
80 extern int kill __P ((__pid_t __pid, int __sig));
81 #endif /* Use POSIX. */
82
83 #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
84 /* Send SIG to all processes in process group PGRP.
85 If PGRP is zero, send SIG to all processes in
86 the current process's process group. */
87 extern int killpg __P ((__pid_t __pgrp, int __sig));
88 #endif /* Use BSD || X/Open Unix. */
89
90 /* Raise signal SIG, i.e., send SIG to yourself. */
91 extern int raise __P ((int __sig));
92
93 #ifdef __USE_SVID
94 /* SVID names for the same things. */
95 extern __sighandler_t ssignal __P ((int __sig, __sighandler_t __handler));
96 extern int gsignal __P ((int __sig));
97 #endif /* Use SVID. */
98
99 #ifdef __USE_MISC
100 /* Print a message describing the meaning of the given signal number. */
101 extern void psignal __P ((int __sig, __const char *__s));
102 #endif /* Use misc. */
103
104
105 /* Block signals in MASK, returning the old mask. */
106 extern int __sigblock __P ((int __mask));
107
108 /* Set the mask of blocked signals to MASK, returning the old mask. */
109 extern int __sigsetmask __P ((int __mask));
110
111
112 /* The `sigpause' function has two different interfaces. The original
113 BSD definition defines the argument as a mask of the signal, while
114 the more modern interface in X/Open defines it as the signal
115 number. We go with the BSD version unless the user explicitly
116 selects the X/Open version. */
117 extern int __sigpause __P ((int __sig_or_mask, int __is_sig));
118
119 #if defined __USE_BSD || defined __USE_GNU
120 /* Set the mask of blocked signals to MASK,
121 wait for a signal to arrive, and then restore the mask. */
122 extern int sigpause __P ((int __mask));
123 #define sigpause(mask) __sigpause ((mask), 0)
124 #else
125 #ifdef __USE_XOPEN
126 /* Remove a signal from the signal mask and suspend the process. */
127 #define sigpause(sig) __sigpause ((sig), 1)
128 #endif
129 #endif
130
131
132 #ifdef __USE_BSD
133 #define sigmask(sig) __sigmask(sig)
134
135 extern int sigblock __P ((int __mask));
136 extern int sigsetmask __P ((int __mask));
137
138 /* This function is here only for compatibility.
139 Use `sigprocmask' instead. */
140 extern int siggetmask __P ((void));
141 #endif /* Use BSD. */
142
143
144 #ifdef __USE_MISC
145 #define NSIG _NSIG
146 #endif
147
148 #ifdef __USE_GNU
149 typedef __sighandler_t sighandler_t;
150 #endif
151
152 /* 4.4 BSD uses the name `sig_t' for this. */
153 #ifdef __USE_BSD
154 typedef __sighandler_t sig_t;
155 #endif
156
157 #endif /* <signal.h> included. */
158
159
160 #ifdef __USE_POSIX
161
162 #if !defined __sigset_t_defined \
163 && (defined _SIGNAL_H || defined __need_sigset_t)
164 typedef __sigset_t sigset_t;
165 #define __sigset_t_defined 1
166 #endif /* `sigset_t' not defined and <signal.h> or need `sigset_t'. */
167 #undef __need_sigset_t
168
169 #ifdef _SIGNAL_H
170
171 /* Clear all signals from SET. */
172 extern int sigemptyset __P ((sigset_t *__set));
173
174 /* Set all signals in SET. */
175 extern int sigfillset __P ((sigset_t *__set));
176
177 /* Add SIGNO to SET. */
178 extern int sigaddset __P ((sigset_t *__set, int __signo));
179
180 /* Remove SIGNO from SET. */
181 extern int sigdelset __P ((sigset_t *__set, int __signo));
182
183 /* Return 1 if SIGNO is in SET, 0 if not. */
184 extern int sigismember __P ((__const sigset_t *__set, int __signo));
185
186 #ifdef __USE_GNU
187 /* Return non-empty value is SET is not empty. */
188 extern int sigisemptyset __P ((__const sigset_t *__set));
189
190 /* Build new signal set by combining the two inputs set using logical AND. */
191 extern int sigandset __P ((sigset_t *__set, __const sigset_t *__left,
192 __const sigset_t *__right));
193
194 /* Build new signal set by combining the two inputs set using logical OR. */
195 extern int sigorset __P ((sigset_t *__set, __const sigset_t *__left,
196 __const sigset_t *__right));
197 #endif /* GNU */
198
199 /* Get the system-specific definitions of `struct sigaction'
200 and the `SA_*' and `SIG_*'. constants. */
201 #include <bits/sigaction.h>
202
203 /* Get and/or change the set of blocked signals. */
204 extern int __sigprocmask __P ((int __how,
205 __const sigset_t *__set, sigset_t *__oset));
206 extern int sigprocmask __P ((int __how,
207 __const sigset_t *__set, sigset_t *__oset));
208
209 /* Change the set of blocked signals to SET,
210 wait until a signal arrives, and restore the set of blocked signals. */
211 extern int __sigsuspend __P ((__const sigset_t *__set));
212 extern int sigsuspend __P ((__const sigset_t *__set));
213
214 /* Get and/or set the action for signal SIG. */
215 extern int __sigaction __P ((int __sig, __const struct sigaction *__act,
216 struct sigaction *__oact));
217 extern int sigaction __P ((int __sig, __const struct sigaction *__act,
218 struct sigaction *__oact));
219
220 /* Put in SET all signals that are blocked and waiting to be delivered. */
221 extern int sigpending __P ((sigset_t *__set));
222
223
224 /* Select any of pending signals from SET or wait for any to arrive. */
225 extern int __sigwait __P ((__const sigset_t *__set, int *__sig));
226 extern int sigwait __P ((__const sigset_t *__set, int *__sig));
227
228 #endif /* <signal.h> included. */
229
230 #endif /* Use POSIX. */
231
232 #if defined _SIGNAL_H && defined __USE_BSD
233
234 /* Names of the signals. This variable exists only for compatibility.
235 Use `strsignal' instead (see <string.h>). */
236 extern __const char *__const _sys_siglist[_NSIG];
237 extern __const char *__const sys_siglist[_NSIG];
238
239 /* Structure passed to `sigvec'. */
240 struct sigvec
241 {
242 __sighandler_t sv_handler; /* Signal handler. */
243 int sv_mask; /* Mask of signals to be blocked. */
244
245 int sv_flags; /* Flags (see below). */
246 #define sv_onstack sv_flags /* 4.2 BSD compatibility. */
247 };
248
249 /* Bits in `sv_flags'. */
250 #define SV_ONSTACK (1 << 0)/* Take the signal on the signal stack. */
251 #define SV_INTERRUPT (1 << 1)/* Do not restart system calls. */
252 #define SV_RESETHAND (1 << 2)/* Reset handler to SIG_DFL on receipt. */
253
254
255 /* If VEC is non-NULL, set the handler for SIG to the `sv_handler' member
256 of VEC. The signals in `sv_mask' will be blocked while the handler runs.
257 If the SV_RESETHAND bit is set in `sv_flags', the handler for SIG will be
258 reset to SIG_DFL before `sv_handler' is entered. If OVEC is non-NULL,
259 it is filled in with the old information for SIG. */
260 extern int __sigvec __P ((int __sig, __const struct sigvec *__vec,
261 struct sigvec *__ovec));
262 extern int sigvec __P ((int __sig, __const struct sigvec *__vec,
263 struct sigvec *__ovec));
264
265
266 /* Get machine-dependent `struct sigcontext' and signal subcodes. */
267 #include <bits/sigcontext.h>
268
269 /* Restore the state saved in SCP. */
270 extern int __sigreturn __P ((struct sigcontext *__scp));
271 extern int sigreturn __P ((struct sigcontext *__scp));
272
273 #endif /* signal.h included and use BSD. */
274
275
276 #if defined _SIGNAL_H && (defined __USE_BSD || defined __USE_XOPEN_EXTENDED)
277
278 #define __need_size_t
279 #include <stddef.h>
280
281 /* If INTERRUPT is nonzero, make signal SIG interrupt system calls
282 (causing them to fail with EINTR); if INTERRUPT is zero, make system
283 calls be restarted after signal SIG. */
284 extern int siginterrupt __P ((int __sig, int __interrupt));
285
286
287 /* Structure describing a signal stack. */
288 struct sigstack
289 {
290 __ptr_t ss_sp; /* Signal stack pointer. */
291 int ss_onstack; /* Nonzero if executing on this stack. */
292 };
293
294 /* Run signals handlers on the stack specified by SS (if not NULL).
295 If OSS is not NULL, it is filled in with the old signal stack status. */
296 extern int sigstack __P ((__const struct sigstack *__ss,
297 struct sigstack *__oss));
298
299 /* Alternate interface. */
300 struct sigaltstack
301 {
302 __ptr_t ss_sp;
303 size_t ss_size;
304 int ss_flags;
305 };
306
307 extern int sigaltstack __P ((__const struct sigaltstack *__ss,
308 struct sigaltstack *__oss));
309
310 #endif /* signal.h included and use BSD or X/Open Unix. */
311
312 __END_DECLS
313
314 #endif /* signal.h */