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