1 /* Copyright (C) 1991, 1992, 1993, 1994, 1995 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
16 not, write to the, 1992 Free Software Foundation, Inc., 675 Mass Ave,
17 Cambridge, MA 02139, USA. */
20 * ANSI Standard: 4.7 SIGNAL HANDLING <signal.h>
25 #if !defined(__need_sig_atomic_t) && !defined(__need_sigset_t)
35 #include <gnu/types.h>
36 #include <sigset.h> /* __sigset_t, __sig_atomic_t. */
38 #if !defined(__sig_atomic_t_defined) && \
39 (defined(_SIGNAL_H) || defined(__need_sig_atomic_t))
40 /* An integral type that can be modified atomically, without the
41 possibility of a signal arriving in the middle of the operation. */
42 typedef __sig_atomic_t sig_atomic_t;
43 #endif /* `sig_atomic_t' undefined and <signal.h> or need `sig_atomic_t'. */
44 #undef __need_sig_atomic_t
50 /* Type of a signal handler. */
51 typedef void (*__sighandler_t) __P ((int));
53 /* Set the handler for the signal SIG to HANDLER,
54 returning the old handler, or SIG_ERR on error. */
55 extern __sighandler_t signal __P ((int __sig, __sighandler_t __handler));
57 /* Send signal SIG to process number PID. If PID is zero,
58 send SIG to all processes in the current process's process group.
59 If PID is < -1, send SIG to all processes in process group - PID. */
60 extern int __kill __P ((__pid_t __pid, int __sig));
62 extern int kill __P ((__pid_t __pid, int __sig));
63 #endif /* Use POSIX. */
66 /* Send SIG to all processes in process group PGRP.
67 If PGRP is zero, send SIG to all processes in
68 the current process's process group. */
69 extern int killpg __P ((__pid_t __pgrp, int __sig));
72 /* Raise signal SIG, i.e., send SIG to yourself. */
73 extern int raise __P ((int __sig));
76 /* SVID names for the same things. */
77 extern __sighandler_t ssignal __P ((int __sig, __sighandler_t __handler));
78 extern int gsignal __P ((int __sig));
79 #endif /* Use SVID. */
82 /* Print a message describing the meaning of the given signal number. */
83 extern void psignal __P ((int __sig, __const char *__s));
84 #endif /* Use misc. */
87 /* Block signals in MASK, returning the old mask. */
88 extern int __sigblock __P ((int __mask));
90 /* Set the mask of blocked signals to MASK, returning the old mask. */
91 extern int __sigsetmask __P ((int __mask));
93 /* Set the mask of blocked signals to MASK,
94 wait for a signal to arrive, and then restore the mask. */
95 extern int __sigpause __P ((int __mask));
98 #define sigmask(sig) __sigmask(sig)
100 extern int sigblock __P ((int __mask));
101 extern int sigsetmask __P ((int __mask));
102 extern int sigpause __P ((int __mask));
103 #endif /* Use BSD. */
111 typedef __sighandler_t sighandler_t;
114 #endif /* <signal.h> included. */
119 #if !defined(__sigset_t_defined) && \
120 (defined(_SIGNAL_H) || defined(__need_sigset_t))
121 typedef __sigset_t sigset_t;
122 #define __sigset_t_defined 1
123 #endif /* `sigset_t' not defined and <signal.h> or need `sigset_t'. */
124 #undef __need_sigset_t
128 /* Clear all signals from SET. */
129 extern int sigemptyset __P ((sigset_t *__set));
131 /* Set all signals in SET. */
132 extern int sigfillset __P ((sigset_t *__set));
134 /* Add SIGNO to SET. */
135 extern int sigaddset __P ((sigset_t *__set, int __signo));
137 /* Remove SIGNO from SET. */
138 extern int sigdelset __P ((sigset_t *__set, int __signo));
140 /* Return 1 if SIGNO is in SET, 0 if not. */
141 extern int sigismember __P ((__const sigset_t *__set, int signo));
144 /* <sigset.h> defines the __ versions as macros that do the work. */
145 #define sigemptyset(set) __sigemptyset(set)
146 #define sigfillset(set) __sigfillset(set)
147 #define sigaddset(set, signo) __sigaddset(set, signo)
148 #define sigdelset(set, signo) __sigdelset(set, signo)
149 #define sigismember(set, signo) __sigismember(set, signo)
152 /* Get the system-specific definitions of `struct sigaction'
153 and the `SA_*' and `SIG_*'. constants. */
154 #include <sigaction.h>
156 /* Get and/or change the set of blocked signals. */
157 extern int __sigprocmask __P ((int __how,
158 __const sigset_t *__set, sigset_t *__oset));
159 extern int sigprocmask __P ((int __how,
160 __const sigset_t *__set, sigset_t *__oset));
162 /* Change the set of blocked signals to SET,
163 wait until a signal arrives, and restore the set of blocked signals. */
164 extern int sigsuspend __P ((__const sigset_t *__set));
166 /* Get and/or set the action for signal SIG. */
167 extern int __sigaction __P ((int __sig, __const struct sigaction *__act,
168 struct sigaction *__oact));
169 extern int sigaction __P ((int __sig, __const struct sigaction *__act,
170 struct sigaction *__oact));
172 /* Put in SET all signals that are blocked and waiting to be delivered. */
173 extern int sigpending __P ((sigset_t *__set));
175 #endif /* <signal.h> included. */
177 #endif /* Use POSIX. */
179 #if defined(_SIGNAL_H) && defined(__USE_BSD)
181 /* Names of the signals. This variable exists only for compatiblity.
182 Use `strsignal' instead (see <string.h>). */
183 extern __const char *__const _sys_siglist[NSIG];
184 extern __const char *__const sys_siglist[NSIG];
186 /* Structure passed to `sigvec'. */
189 __sighandler_t sv_handler; /* Signal handler. */
190 int sv_mask; /* Mask of signals to be blocked. */
192 int sv_flags; /* Flags (see below). */
193 #define sv_onstack sv_flags /* 4.2 BSD compatibility. */
196 /* Bits in `sv_flags'. */
197 #define SV_ONSTACK (1 << 0)/* Take the signal on the signal stack. */
198 #define SV_INTERRUPT (1 << 1)/* Do not restart system calls. */
199 #define SV_RESETHAND (1 << 2)/* Reset handler to SIG_DFL on receipt. */
202 /* If VEC is non-NULL, set the handler for SIG to the `sv_handler' member
203 of VEC. The signals in `sv_mask' will be blocked while the handler runs.
204 If the SV_RESETHAND bit is set in `sv_flags', the handler for SIG will be
205 reset to SIG_DFL before `sv_handler' is entered. If OVEC is non-NULL,
206 it is filled in with the old information for SIG. */
207 extern int __sigvec __P ((int __sig, __const struct sigvec *__vec,
208 struct sigvec *__ovec));
209 extern int sigvec __P ((int __sig, __const struct sigvec *__vec,
210 struct sigvec *__ovec));
213 /* If INTERRUPT is nonzero, make signal SIG interrupt system calls
214 (causing them to fail with EINTR); if INTERRUPT is zero, make system
215 calls be restarted after signal SIG. */
216 extern int siginterrupt __P ((int __sig, int __interrupt));
219 /* Structure describing a signal stack. */
222 __ptr_t ss_sp; /* Signal stack pointer. */
223 int ss_onstack; /* Nonzero if executing on this stack. */
226 /* Run signals handlers on the stack specified by SS (if not NULL).
227 If OSS is not NULL, it is filled in with the old signal stack status. */
228 extern int sigstack __P ((__const struct sigstack *__ss,
229 struct sigstack *__oss));
231 /* Alternate interface. */
239 extern int sigaltstack __P ((__const struct sigaltstack *__ss,
240 struct sigaltstack *__oss));
242 /* Get machine-dependent `struct sigcontext' and signal subcodes. */
243 #include <sigcontext.h>
245 /* Restore the state saved in SCP. */
246 extern int __sigreturn __P ((struct sigcontext *__scp));
247 extern int sigreturn __P ((struct sigcontext *__scp));
249 #endif /* signal.h included and use BSD. */
253 #endif /* signal.h */