update from main archive 960105
[glibc/history.git] / signal / signal.h
blobcd833e87835cd91e1104683e7e1647eb16cbd8b5
1 /* Copyright (C) 1991, 92, 93, 94, 95, 96, 97 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 <gnu/types.h>
33 #include <sigset.h> /* __sigset_t, __sig_atomic_t. */
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
43 #ifdef _SIGNAL_H
45 #include <signum.h>
47 /* Type of a signal handler. */
48 typedef void (*__sighandler_t) __P ((int));
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));
55 #if defined __USE_XOPEN && !defined __USE_GNU
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 extern __sighandler_t sysv_signal __P ((int __sig, __sighandler_t __handler));
63 /* Make sure the used `signal' implementation is the SVID version. */
64 #define signal(sig, handler) __sysv_signal ((sig), (handler))
65 #endif
67 #ifdef __USE_XOPEN
68 /* The X/Open definition of `signal' conflicts with the BSD version.
69 So they defined another function `bsd_signal'. */
70 extern __sighandler_t __bsd_signal __P ((int __sig, __sighandler_t __handler));
71 extern __sighandler_t bsd_signal __P ((int __sig, __sighandler_t __handler));
72 #endif
74 /* Send signal SIG to process number PID. If PID is zero,
75 send SIG to all processes in the current process's process group.
76 If PID is < -1, send SIG to all processes in process group - PID. */
77 extern int __kill __P ((__pid_t __pid, int __sig));
78 #ifdef __USE_POSIX
79 extern int kill __P ((__pid_t __pid, int __sig));
80 #endif /* Use POSIX. */
82 #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
83 /* Send SIG to all processes in process group PGRP.
84 If PGRP is zero, send SIG to all processes in
85 the current process's process group. */
86 extern int killpg __P ((__pid_t __pgrp, int __sig));
87 #endif /* Use BSD || X/Open Unix. */
89 /* Raise signal SIG, i.e., send SIG to yourself. */
90 extern int raise __P ((int __sig));
92 #ifdef __USE_SVID
93 /* SVID names for the same things. */
94 extern __sighandler_t ssignal __P ((int __sig, __sighandler_t __handler));
95 extern int gsignal __P ((int __sig));
96 #endif /* Use SVID. */
98 #ifdef __USE_MISC
99 /* Print a message describing the meaning of the given signal number. */
100 extern void psignal __P ((int __sig, __const char *__s));
101 #endif /* Use misc. */
104 /* Block signals in MASK, returning the old mask. */
105 extern int __sigblock __P ((int __mask));
107 /* Set the mask of blocked signals to MASK, returning the old mask. */
108 extern int __sigsetmask __P ((int __mask));
111 /* The `sigpause' function has two different interfaces. The original
112 BSD definition defines the argument as a mask of the signal, while
113 the more modern interface in X/Open defines it as the signal
114 number. We go with the BSD version unless the user explicitly
115 selects the X/Open version. */
116 extern int __sigpause __P ((int __sig_or_mask, int __is_sig));
118 #if defined __USE_BSD || defined __USE_GNU
119 /* Set the mask of blocked signals to MASK,
120 wait for a signal to arrive, and then restore the mask. */
121 extern int sigpause __P ((int __mask));
122 #define sigpause(mask) __sigpause ((mask), 0)
123 #else
124 #ifdef __USE_XOPEN
125 /* Remove a signal from the signal mask and suspend the process. */
126 #define sigpause(sig) __sigpause ((sig), 1)
127 #endif
128 #endif
131 #ifdef __USE_BSD
132 #define sigmask(sig) __sigmask(sig)
134 extern int sigblock __P ((int __mask));
135 extern int sigsetmask __P ((int __mask));
137 /* This function is here only for compatibility.
138 Use `sigprocmask' instead. */
139 extern int siggetmask __P ((void));
140 #endif /* Use BSD. */
143 #ifdef __USE_MISC
144 #define NSIG _NSIG
145 #endif
147 #ifdef __USE_GNU
148 typedef __sighandler_t sighandler_t;
149 #endif
151 /* 4.4 BSD uses the name `sig_t' for this. */
152 #ifdef __USE_BSD
153 typedef __sighandler_t sig_t;
154 #endif
156 #endif /* <signal.h> included. */
159 #ifdef __USE_POSIX
161 #if !defined __sigset_t_defined \
162 && (defined _SIGNAL_H || defined __need_sigset_t)
163 typedef __sigset_t sigset_t;
164 #define __sigset_t_defined 1
165 #endif /* `sigset_t' not defined and <signal.h> or need `sigset_t'. */
166 #undef __need_sigset_t
168 #ifdef _SIGNAL_H
170 /* Clear all signals from SET. */
171 extern int sigemptyset __P ((sigset_t *__set));
173 /* Set all signals in SET. */
174 extern int sigfillset __P ((sigset_t *__set));
176 /* Add SIGNO to SET. */
177 extern int sigaddset __P ((sigset_t *__set, int __signo));
179 /* Remove SIGNO from SET. */
180 extern int sigdelset __P ((sigset_t *__set, int __signo));
182 /* Return 1 if SIGNO is in SET, 0 if not. */
183 extern int sigismember __P ((__const sigset_t *__set, int __signo));
185 /* Get the system-specific definitions of `struct sigaction'
186 and the `SA_*' and `SIG_*'. constants. */
187 #include <sigaction.h>
189 /* Get and/or change the set of blocked signals. */
190 extern int __sigprocmask __P ((int __how,
191 __const sigset_t *__set, sigset_t *__oset));
192 extern int sigprocmask __P ((int __how,
193 __const sigset_t *__set, sigset_t *__oset));
195 /* Change the set of blocked signals to SET,
196 wait until a signal arrives, and restore the set of blocked signals. */
197 extern int __sigsuspend __P ((__const sigset_t *__set));
198 extern int sigsuspend __P ((__const sigset_t *__set));
200 /* Get and/or set the action for signal SIG. */
201 extern int __sigaction __P ((int __sig, __const struct sigaction *__act,
202 struct sigaction *__oact));
203 extern int sigaction __P ((int __sig, __const struct sigaction *__act,
204 struct sigaction *__oact));
206 /* Put in SET all signals that are blocked and waiting to be delivered. */
207 extern int sigpending __P ((sigset_t *__set));
210 /* Select any of pending signals from SET or wait for any to arrive. */
211 extern int __sigwait __P ((__const sigset_t *__set, int *__sig));
212 extern int sigwait __P ((__const sigset_t *__set, int *__sig));
214 #endif /* <signal.h> included. */
216 #endif /* Use POSIX. */
218 #if defined _SIGNAL_H && defined __USE_BSD
220 /* Names of the signals. This variable exists only for compatibility.
221 Use `strsignal' instead (see <string.h>). */
222 extern __const char *__const _sys_siglist[NSIG];
223 extern __const char *__const sys_siglist[NSIG];
225 /* Structure passed to `sigvec'. */
226 struct sigvec
228 __sighandler_t sv_handler; /* Signal handler. */
229 int sv_mask; /* Mask of signals to be blocked. */
231 int sv_flags; /* Flags (see below). */
232 #define sv_onstack sv_flags /* 4.2 BSD compatibility. */
235 /* Bits in `sv_flags'. */
236 #define SV_ONSTACK (1 << 0)/* Take the signal on the signal stack. */
237 #define SV_INTERRUPT (1 << 1)/* Do not restart system calls. */
238 #define SV_RESETHAND (1 << 2)/* Reset handler to SIG_DFL on receipt. */
241 /* If VEC is non-NULL, set the handler for SIG to the `sv_handler' member
242 of VEC. The signals in `sv_mask' will be blocked while the handler runs.
243 If the SV_RESETHAND bit is set in `sv_flags', the handler for SIG will be
244 reset to SIG_DFL before `sv_handler' is entered. If OVEC is non-NULL,
245 it is filled in with the old information for SIG. */
246 extern int __sigvec __P ((int __sig, __const struct sigvec *__vec,
247 struct sigvec *__ovec));
248 extern int sigvec __P ((int __sig, __const struct sigvec *__vec,
249 struct sigvec *__ovec));
252 /* Get machine-dependent `struct sigcontext' and signal subcodes. */
253 #include <sigcontext.h>
255 /* Restore the state saved in SCP. */
256 extern int __sigreturn __P ((struct sigcontext *__scp));
257 extern int sigreturn __P ((struct sigcontext *__scp));
259 #endif /* signal.h included and use BSD. */
262 #if defined _SIGNAL_H && (defined __USE_BSD || defined __USE_XOPEN_EXTENDED)
264 #define __need_size_t
265 #include <stddef.h>
267 /* If INTERRUPT is nonzero, make signal SIG interrupt system calls
268 (causing them to fail with EINTR); if INTERRUPT is zero, make system
269 calls be restarted after signal SIG. */
270 extern int siginterrupt __P ((int __sig, int __interrupt));
273 /* Structure describing a signal stack. */
274 struct sigstack
276 __ptr_t ss_sp; /* Signal stack pointer. */
277 int ss_onstack; /* Nonzero if executing on this stack. */
280 /* Run signals handlers on the stack specified by SS (if not NULL).
281 If OSS is not NULL, it is filled in with the old signal stack status. */
282 extern int sigstack __P ((__const struct sigstack *__ss,
283 struct sigstack *__oss));
285 /* Alternate interface. */
286 struct sigaltstack
288 __ptr_t ss_sp;
289 size_t ss_size;
290 int ss_flags;
293 extern int sigaltstack __P ((__const struct sigaltstack *__ss,
294 struct sigaltstack *__oss));
296 #endif /* signal.h included and use BSD or X/Open Unix. */
298 __END_DECLS
300 #endif /* signal.h */