gconv conversion module definition for IEC_P27-1.
[glibc/history.git] / signal / signal.h
blob93058973a9e4b264570155cc098d2f3e7ecf8480
1 /* Copyright (C) 1991,92,93,94,95,96,97,98 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
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.
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.
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. */
20 * ISO C Standard: 4.7 SIGNAL HANDLING <signal.h>
23 #ifndef _SIGNAL_H
25 #if !defined __need_sig_atomic_t && !defined __need_sigset_t
26 # define _SIGNAL_H 1
27 # include <features.h>
28 #endif
30 __BEGIN_DECLS
32 #include <bits/types.h>
33 #include <bits/sigset.h> /* __sigset_t, __sig_atomic_t. */
35 #if defined _SIGNAL_H && defined __USE_XOPEN && !defined pid_t
36 typedef __pid_t pid_t;
37 # define pid_t pid_t
38 #endif /* Unix98 */
40 #if !defined __sig_atomic_t_defined \
41 && (defined _SIGNAL_H || defined __need_sig_atomic_t)
42 /* An integral type that can be modified atomically, without the
43 possibility of a signal arriving in the middle of the operation. */
44 typedef __sig_atomic_t sig_atomic_t;
45 # define __sig_atomic_t_defined
46 #endif /* `sig_atomic_t' undefined and <signal.h> or need `sig_atomic_t'. */
47 #undef __need_sig_atomic_t
49 #ifdef _SIGNAL_H
51 #include <bits/signum.h>
53 /* Type of a signal handler. */
54 typedef void (*__sighandler_t) __PMT ((int));
56 /* The X/Open definition of `signal' specifies the SVID semantic. Use
57 the additional function `sysv_signal' when X/Open compatibility is
58 requested. */
59 extern __sighandler_t __sysv_signal __P ((int __sig,
60 __sighandler_t __handler));
61 #ifdef __USE_GNU
62 extern __sighandler_t sysv_signal __P ((int __sig, __sighandler_t __handler));
63 #endif
65 /* Set the handler for the signal SIG to HANDLER, returning the old
66 handler, or SIG_ERR on error.
67 By default `signal' has the BSD semantic. */
68 #ifdef __USE_BSD
69 extern __sighandler_t signal __P ((int __sig, __sighandler_t __handler));
70 #else
71 /* Make sure the used `signal' implementation is the SVID version. */
72 # ifdef __REDIRECT
73 extern __sighandler_t __REDIRECT (signal,
74 __P ((int __sig, __sighandler_t __handler)),
75 __sysv_signal);
76 # else
77 # define signal __sysv_signal
78 # endif
79 #endif
81 #ifdef __USE_XOPEN
82 /* The X/Open definition of `signal' conflicts with the BSD version.
83 So they defined another function `bsd_signal'. */
84 extern __sighandler_t bsd_signal __P ((int __sig, __sighandler_t __handler));
85 #endif
87 /* Send signal SIG to process number PID. If PID is zero,
88 send SIG to all processes in the current process's process group.
89 If PID is < -1, send SIG to all processes in process group - PID. */
90 #ifdef __USE_POSIX
91 extern int kill __P ((__pid_t __pid, int __sig));
92 #endif /* Use POSIX. */
94 #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
95 /* Send SIG to all processes in process group PGRP.
96 If PGRP is zero, send SIG to all processes in
97 the current process's process group. */
98 extern int killpg __P ((__pid_t __pgrp, int __sig));
99 #endif /* Use BSD || X/Open Unix. */
101 /* Raise signal SIG, i.e., send SIG to yourself. */
102 extern int raise __P ((int __sig));
104 #ifdef __USE_SVID
105 /* SVID names for the same things. */
106 extern __sighandler_t ssignal __P ((int __sig, __sighandler_t __handler));
107 extern int gsignal __P ((int __sig));
108 #endif /* Use SVID. */
110 #ifdef __USE_MISC
111 /* Print a message describing the meaning of the given signal number. */
112 extern void psignal __P ((int __sig, __const char *__s));
113 #endif /* Use misc. */
116 /* The `sigpause' function has two different interfaces. The original
117 BSD definition defines the argument as a mask of the signal, while
118 the more modern interface in X/Open defines it as the signal
119 number. We go with the BSD version unless the user explicitly
120 selects the X/Open version. */
121 extern int __sigpause __P ((int __sig_or_mask, int __is_sig));
123 #if defined __USE_BSD || defined __USE_GNU
124 /* Set the mask of blocked signals to MASK,
125 wait for a signal to arrive, and then restore the mask. */
126 extern int sigpause __P ((int __mask));
127 # define sigpause(mask) __sigpause ((mask), 0)
128 #else
129 # ifdef __USE_XOPEN
130 /* Remove a signal from the signal mask and suspend the process. */
131 # define sigpause(sig) __sigpause ((sig), 1)
132 # endif
133 #endif
136 #ifdef __USE_BSD
137 /* None of the following functions should be used anymore. They are here
138 only for compatibility. A single word (`int') is not guaranteed to be
139 enough to hold a complete signal mask and therefore these functions
140 simply do not work in many situations. Use `sigprocmask' instead. */
142 /* Compute mask for signal SIG. */
143 # define sigmask(sig) __sigmask(sig)
145 /* Block signals in MASK, returning the old mask. */
146 extern int sigblock __P ((int __mask));
148 /* Set the mask of blocked signals to MASK, returning the old mask. */
149 extern int sigsetmask __P ((int __mask));
151 /* Return currently selected signal mask. */
152 extern int siggetmask __P ((void));
153 #endif /* Use BSD. */
156 #ifdef __USE_MISC
157 # define NSIG _NSIG
158 #endif
160 #ifdef __USE_GNU
161 typedef __sighandler_t sighandler_t;
162 #endif
164 /* 4.4 BSD uses the name `sig_t' for this. */
165 #ifdef __USE_BSD
166 typedef __sighandler_t sig_t;
167 #endif
169 #endif /* <signal.h> included. */
172 #if !defined __sigset_t_defined \
173 && ((defined _SIGNAL_H && defined __USE_POSIX) || defined __need_sigset_t)
174 typedef __sigset_t sigset_t;
175 # define __sigset_t_defined 1
176 #endif /* `sigset_t' not defined and <signal.h> or need `sigset_t'. */
177 #undef __need_sigset_t
179 #ifdef __USE_POSIX
181 # ifdef _SIGNAL_H
183 /* We need `struct timespec' later on. */
184 # define __need_timespec
185 # include <time.h>
187 /* Get the `siginfo_t' type plus the needed symbols. */
188 # include <bits/siginfo.h>
190 /* Clear all signals from SET. */
191 extern int sigemptyset __P ((sigset_t *__set));
193 /* Set all signals in SET. */
194 extern int sigfillset __P ((sigset_t *__set));
196 /* Add SIGNO to SET. */
197 extern int sigaddset __P ((sigset_t *__set, int __signo));
199 /* Remove SIGNO from SET. */
200 extern int sigdelset __P ((sigset_t *__set, int __signo));
202 /* Return 1 if SIGNO is in SET, 0 if not. */
203 extern int sigismember __P ((__const sigset_t *__set, int __signo));
205 # ifdef __USE_GNU
206 /* Return non-empty value is SET is not empty. */
207 extern int sigisemptyset __P ((__const sigset_t *__set));
209 /* Build new signal set by combining the two inputs set using logical AND. */
210 extern int sigandset __P ((sigset_t *__set, __const sigset_t *__left,
211 __const sigset_t *__right));
213 /* Build new signal set by combining the two inputs set using logical OR. */
214 extern int sigorset __P ((sigset_t *__set, __const sigset_t *__left,
215 __const sigset_t *__right));
216 # endif /* GNU */
218 /* Get the system-specific definitions of `struct sigaction'
219 and the `SA_*' and `SIG_*'. constants. */
220 # include <bits/sigaction.h>
222 /* Get and/or change the set of blocked signals. */
223 extern int sigprocmask __P ((int __how,
224 __const sigset_t *__set, sigset_t *__oset));
226 /* Change the set of blocked signals to SET,
227 wait until a signal arrives, and restore the set of blocked signals. */
228 extern int sigsuspend __P ((__const sigset_t *__set));
230 /* Get and/or set the action for signal SIG. */
231 extern int __sigaction __P ((int __sig, __const struct sigaction *__act,
232 struct sigaction *__oact));
233 extern int sigaction __P ((int __sig, __const struct sigaction *__act,
234 struct sigaction *__oact));
236 /* Put in SET all signals that are blocked and waiting to be delivered. */
237 extern int sigpending __P ((sigset_t *__set));
240 /* Select any of pending signals from SET or wait for any to arrive. */
241 extern int sigwait __P ((__const sigset_t *__set, int *__sig));
243 /* Select any of pending signals from SET and place information in INFO. */
244 extern int sigwaitinfo __P ((__const sigset_t *__set, siginfo_t *__info));
246 /* Select any of pending signals from SET and place information in INFO.
247 Wait the imte specified by TIMEOUT if no signal is pending. */
248 extern int sigtimedwait __P ((__const sigset_t *__set, siginfo_t *__info,
249 __const struct timespec *__timeout));
251 /* Send signal SIG to the process PID. Associate data in VAL with the
252 signal. */
253 extern int sigqueue __P ((__pid_t __pid, int __sig,
254 __const union sigval __val));
256 # endif /* <signal.h> included. */
258 #endif /* Use POSIX. */
260 #if defined _SIGNAL_H && defined __USE_BSD
262 /* Names of the signals. This variable exists only for compatibility.
263 Use `strsignal' instead (see <string.h>). */
264 extern __const char *__const _sys_siglist[_NSIG];
265 extern __const char *__const sys_siglist[_NSIG];
267 /* Structure passed to `sigvec'. */
268 struct sigvec
270 __sighandler_t sv_handler; /* Signal handler. */
271 int sv_mask; /* Mask of signals to be blocked. */
273 int sv_flags; /* Flags (see below). */
274 # define sv_onstack sv_flags /* 4.2 BSD compatibility. */
277 /* Bits in `sv_flags'. */
278 # define SV_ONSTACK (1 << 0)/* Take the signal on the signal stack. */
279 # define SV_INTERRUPT (1 << 1)/* Do not restart system calls. */
280 # define SV_RESETHAND (1 << 2)/* Reset handler to SIG_DFL on receipt. */
283 /* If VEC is non-NULL, set the handler for SIG to the `sv_handler' member
284 of VEC. The signals in `sv_mask' will be blocked while the handler runs.
285 If the SV_RESETHAND bit is set in `sv_flags', the handler for SIG will be
286 reset to SIG_DFL before `sv_handler' is entered. If OVEC is non-NULL,
287 it is filled in with the old information for SIG. */
288 extern int sigvec __P ((int __sig, __const struct sigvec *__vec,
289 struct sigvec *__ovec));
292 /* Get machine-dependent `struct sigcontext' and signal subcodes. */
293 # include <bits/sigcontext.h>
295 /* Restore the state saved in SCP. */
296 extern int sigreturn __P ((struct sigcontext *__scp));
298 #endif /* signal.h included and use BSD. */
301 #if defined _SIGNAL_H && (defined __USE_BSD || defined __USE_XOPEN_EXTENDED)
303 # define __need_size_t
304 # include <stddef.h>
306 /* If INTERRUPT is nonzero, make signal SIG interrupt system calls
307 (causing them to fail with EINTR); if INTERRUPT is zero, make system
308 calls be restarted after signal SIG. */
309 extern int siginterrupt __P ((int __sig, int __interrupt));
311 # include <bits/sigstack.h>
313 /* Run signals handlers on the stack specified by SS (if not NULL).
314 If OSS is not NULL, it is filled in with the old signal stack status.
315 This interface is obsolete and on many platform not implemented. */
316 extern int sigstack __P ((__const struct sigstack *__ss,
317 struct sigstack *__oss));
319 /* Alternate signal handler stack interface.
320 This interface should always be preferred over `sigstack'. */
321 extern int sigaltstack __P ((__const struct sigaltstack *__ss,
322 struct sigaltstack *__oss));
324 #endif /* signal.h included and use BSD or X/Open Unix. */
327 #if defined _SIGNAL_H && defined __USE_UNIX98
328 /* Simplified interface for signal management. */
330 /* Add SIG to the calling process' signal mask. */
331 extern int sighold __P ((int __sig));
333 /* Remove SIG from the calling process' signal mask. */
334 extern int sigrelse __P ((int __sig));
336 /* Set the disposition of SIG to SIG_IGN. */
337 extern int sigignore __P ((int __sig));
339 /* Set the disposition of SIG. */
340 extern __sighandler_t sigset __P ((int __sig, __sighandler_t __disp));
341 #endif
343 #ifdef __USE_POSIX
344 /* Some of the functions for handling signals in threaded programs must
345 be defined here. */
346 # include <bits/sigthread.h>
347 #endif
349 /* The following functions are used internally in the C library and in
350 other code which need deep insights. */
352 /* Return number of available real-time signal with highest priority. */
353 extern int __libc_current_sigrtmin __P ((void));
354 /* Return number of available real-time signal with lowest priority. */
355 extern int __libc_current_sigrtmax __P ((void));
357 /* Allocate real-time signal with highest/lowest available priority. */
358 extern int __libc_allocate_rtsig __P ((int __high));
360 __END_DECLS
362 #endif /* signal.h */