1 /* Copyright (C) 1991, 92, 93, 94, 95, 96 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>
25 #if !defined(__need_sig_atomic_t) && !defined(__need_sigset_t)
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
47 /* Type of a signal handler. */
48 typedef void (*__sighandler_t) __P ((int));
50 /* Set the handler for the signal SIG to HANDLER,
51 returning the old handler, or SIG_ERR on error. */
52 extern __sighandler_t signal __P ((int __sig, __sighandler_t __handler));
54 /* Send signal SIG to process number PID. If PID is zero,
55 send SIG to all processes in the current process's process group.
56 If PID is < -1, send SIG to all processes in process group - PID. */
57 extern int __kill __P ((__pid_t __pid, int __sig));
59 extern int kill __P ((__pid_t __pid, int __sig));
60 #endif /* Use POSIX. */
62 #if defined(__USE_BSD) || defined(__USE_XOPEN_EXTENDED)
63 /* Send SIG to all processes in process group PGRP.
64 If PGRP is zero, send SIG to all processes in
65 the current process's process group. */
66 extern int killpg __P ((__pid_t __pgrp, int __sig));
67 #endif /* Use BSD || X/Open Unix. */
69 /* Raise signal SIG, i.e., send SIG to yourself. */
70 extern int raise __P ((int __sig));
73 /* SVID names for the same things. */
74 extern __sighandler_t ssignal __P ((int __sig, __sighandler_t __handler));
75 extern int gsignal __P ((int __sig));
76 #endif /* Use SVID. */
79 /* Print a message describing the meaning of the given signal number. */
80 extern void psignal __P ((int __sig, __const char *__s));
81 #endif /* Use misc. */
84 /* Block signals in MASK, returning the old mask. */
85 extern int __sigblock __P ((int __mask));
87 /* Set the mask of blocked signals to MASK, returning the old mask. */
88 extern int __sigsetmask __P ((int __mask));
91 /* The `sigpause' function has two different interfaces. The original
92 BSD definition defines the argument as a mask of the signal, while
93 the more modern interface in X/Open defines it as the signal
94 number. We go with the more modern version unless the user
95 explitcly selects the BSD version. */
96 extern int __sigpause __P ((int __sig_or_mask, int __is_sig));
98 #if defined(__USE_BSD) && !defined(__USE_XOPEN)
99 /* Set the mask of blocked signals to MASK,
100 wait for a signal to arrive, and then restore the mask. */
101 #define sigpause(mask) __sigpause ((mask), 0)
104 /* Remove a signal from the signal mask and suspend the process. */
105 #define sigpause(sig) __sigpause ((sig), 1)
111 #define sigmask(sig) __sigmask(sig)
113 extern int sigblock __P ((int __mask));
114 extern int sigsetmask __P ((int __mask));
116 /* This function is here only for compatibility.
117 Use `sigprocmask' instead. */
118 extern int siggetmask __P ((void));
119 #endif /* Use BSD. */
127 typedef __sighandler_t sighandler_t;
130 /* 4.4 BSD uses the name `sig_t' for this. */
132 typedef __sighandler_t sig_t;
135 #endif /* <signal.h> included. */
140 #if !defined(__sigset_t_defined) && \
141 (defined(_SIGNAL_H) || defined(__need_sigset_t))
142 typedef __sigset_t sigset_t;
143 #define __sigset_t_defined 1
144 #endif /* `sigset_t' not defined and <signal.h> or need `sigset_t'. */
145 #undef __need_sigset_t
149 /* Clear all signals from SET. */
150 extern int sigemptyset __P ((sigset_t *__set));
152 /* Set all signals in SET. */
153 extern int sigfillset __P ((sigset_t *__set));
155 /* Add SIGNO to SET. */
156 extern int sigaddset __P ((sigset_t *__set, int __signo));
158 /* Remove SIGNO from SET. */
159 extern int sigdelset __P ((sigset_t *__set, int __signo));
161 /* Return 1 if SIGNO is in SET, 0 if not. */
162 extern int sigismember __P ((__const sigset_t *__set, int __signo));
164 /* Get the system-specific definitions of `struct sigaction'
165 and the `SA_*' and `SIG_*'. constants. */
166 #include <sigaction.h>
168 /* Get and/or change the set of blocked signals. */
169 extern int __sigprocmask __P ((int __how,
170 __const sigset_t *__set, sigset_t *__oset));
171 extern int sigprocmask __P ((int __how,
172 __const sigset_t *__set, sigset_t *__oset));
174 /* Change the set of blocked signals to SET,
175 wait until a signal arrives, and restore the set of blocked signals. */
176 extern int __sigsuspend __P ((__const sigset_t *__set));
177 extern int sigsuspend __P ((__const sigset_t *__set));
179 /* Get and/or set the action for signal SIG. */
180 extern int __sigaction __P ((int __sig, __const struct sigaction *__act,
181 struct sigaction *__oact));
182 extern int sigaction __P ((int __sig, __const struct sigaction *__act,
183 struct sigaction *__oact));
185 /* Put in SET all signals that are blocked and waiting to be delivered. */
186 extern int sigpending __P ((sigset_t *__set));
189 /* Select any of pending signals from SET or wait for any to arrive. */
190 extern int __sigwait __P ((__const sigset_t *__set, int *__sig));
191 extern int sigwait __P ((__const sigset_t *__set, int *__sig));
193 #endif /* <signal.h> included. */
195 #endif /* Use POSIX. */
197 #if defined(_SIGNAL_H) && defined(__USE_BSD)
199 /* Names of the signals. This variable exists only for compatibility.
200 Use `strsignal' instead (see <string.h>). */
201 extern __const char *__const _sys_siglist[NSIG];
202 extern __const char *__const sys_siglist[NSIG];
204 /* Structure passed to `sigvec'. */
207 __sighandler_t sv_handler; /* Signal handler. */
208 int sv_mask; /* Mask of signals to be blocked. */
210 int sv_flags; /* Flags (see below). */
211 #define sv_onstack sv_flags /* 4.2 BSD compatibility. */
214 /* Bits in `sv_flags'. */
215 #define SV_ONSTACK (1 << 0)/* Take the signal on the signal stack. */
216 #define SV_INTERRUPT (1 << 1)/* Do not restart system calls. */
217 #define SV_RESETHAND (1 << 2)/* Reset handler to SIG_DFL on receipt. */
220 /* If VEC is non-NULL, set the handler for SIG to the `sv_handler' member
221 of VEC. The signals in `sv_mask' will be blocked while the handler runs.
222 If the SV_RESETHAND bit is set in `sv_flags', the handler for SIG will be
223 reset to SIG_DFL before `sv_handler' is entered. If OVEC is non-NULL,
224 it is filled in with the old information for SIG. */
225 extern int __sigvec __P ((int __sig, __const struct sigvec *__vec,
226 struct sigvec *__ovec));
227 extern int sigvec __P ((int __sig, __const struct sigvec *__vec,
228 struct sigvec *__ovec));
231 /* Get machine-dependent `struct sigcontext' and signal subcodes. */
232 #include <sigcontext.h>
234 /* Restore the state saved in SCP. */
235 extern int __sigreturn __P ((struct sigcontext *__scp));
236 extern int sigreturn __P ((struct sigcontext *__scp));
238 #endif /* signal.h included and use BSD. */
241 #if defined(_SIGNAL_H) && (defined(__USE_BSD) || defined(__USE_XOPEN_EXTENDED))
243 #define __need_size_t
246 /* If INTERRUPT is nonzero, make signal SIG interrupt system calls
247 (causing them to fail with EINTR); if INTERRUPT is zero, make system
248 calls be restarted after signal SIG. */
249 extern int siginterrupt __P ((int __sig, int __interrupt));
252 /* Structure describing a signal stack. */
255 __ptr_t ss_sp; /* Signal stack pointer. */
256 int ss_onstack; /* Nonzero if executing on this stack. */
259 /* Run signals handlers on the stack specified by SS (if not NULL).
260 If OSS is not NULL, it is filled in with the old signal stack status. */
261 extern int sigstack __P ((__const struct sigstack *__ss,
262 struct sigstack *__oss));
264 /* Alternate interface. */
272 extern int sigaltstack __P ((__const struct sigaltstack *__ss,
273 struct sigaltstack *__oss));
275 #endif /* signal.h included and use BSD or X/Open Unix. */
279 #endif /* signal.h */