OSDN Git Service

signal.h: disable ssignal and gsignal
[uclinux-h8/uClibc.git] / include / signal.h
1 /* Copyright (C) 1991-2003, 2004 Free Software Foundation, Inc.
2    This file is part of the GNU C Library.
3
4    The GNU C Library is free software; you can redistribute it and/or
5    modify it under the terms of the GNU Lesser General Public
6    License as published by the Free Software Foundation; either
7    version 2.1 of the License, or (at your option) any later version.
8
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    Lesser General Public License for more details.
13
14    You should have received a copy of the GNU Lesser General Public
15    License along with the GNU C Library; if not, write to the Free
16    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
17    02111-1307 USA.  */
18
19 /*
20  *      ISO C99 Standard: 7.14 Signal handling <signal.h>
21  */
22
23 #ifndef _SIGNAL_H
24
25 #if !defined __need_sig_atomic_t && !defined __need_sigset_t
26 # define _SIGNAL_H
27 #endif
28
29 #include <features.h>
30
31 __BEGIN_DECLS
32
33 #include <bits/sigset.h>                /* __sigset_t, __sig_atomic_t.  */
34
35 /* An integral type that can be modified atomically, without the
36    possibility of a signal arriving in the middle of the operation.  */
37 #if defined __need_sig_atomic_t || defined _SIGNAL_H
38 # ifndef __sig_atomic_t_defined
39 #  define __sig_atomic_t_defined
40 __BEGIN_NAMESPACE_STD
41 typedef __sig_atomic_t sig_atomic_t;
42 __END_NAMESPACE_STD
43 # endif
44 # undef __need_sig_atomic_t
45 #endif
46
47 #if defined __need_sigset_t || (defined _SIGNAL_H && defined __USE_POSIX)
48 # ifndef __sigset_t_defined
49 #  define __sigset_t_defined
50 typedef __sigset_t sigset_t;
51 # endif
52 # undef __need_sigset_t
53 #endif
54
55 #ifdef _SIGNAL_H
56
57 #include <bits/types.h>
58 #include <bits/signum.h>
59
60 /* Fake signal functions.  */
61 #define SIG_ERR    ((__sighandler_t) -1) /* Error return.  */
62 #define SIG_DFL    ((__sighandler_t) 0)  /* Default action.  */
63 #define SIG_IGN    ((__sighandler_t) 1)  /* Ignore signal.  */
64 #ifdef __USE_UNIX98
65 # define SIG_HOLD  ((__sighandler_t) 2)  /* Add signal to hold mask.  */
66 #endif
67 /* Biggest signal number + 1 (including real-time signals).  */
68 #ifndef _NSIG /* if arch has not defined it in bits/signum.h... */
69 # define _NSIG 65
70 #endif
71 #ifdef __USE_MISC
72 # define NSIG _NSIG
73 #endif
74 /* Real-time signal range */
75 #define SIGRTMIN   (__libc_current_sigrtmin())
76 #define SIGRTMAX   (__libc_current_sigrtmax())
77 /* These are the hard limits of the kernel.  These values should not be
78    used directly at user level.  */
79 #ifndef __SIGRTMIN /* if arch has not defined it in bits/signum.h... */
80 # define __SIGRTMIN 32
81 #endif
82 #define __SIGRTMAX (_NSIG - 1)
83
84
85 #if defined __USE_XOPEN || defined __USE_XOPEN2K
86 # ifndef __pid_t_defined
87 typedef __pid_t pid_t;
88 #  define __pid_t_defined
89 # endif
90 # ifndef __uid_t_defined
91 typedef __uid_t uid_t;
92 #  define __uid_t_defined
93 # endif
94 #endif  /* Unix98 */
95
96
97 /* Type of a signal handler.  */
98 typedef void (*__sighandler_t) (int);
99 #if defined __UCLIBC_HAS_OBSOLETE_SYSV_SIGNAL__
100 /* The X/Open definition of `signal' specifies the SVID semantic.  Use
101    the additional function `sysv_signal' when X/Open compatibility is
102    requested.  */
103 extern __sighandler_t __sysv_signal (int __sig, __sighandler_t __handler)
104      __THROW;
105 # ifdef __USE_GNU
106 extern __sighandler_t sysv_signal (int __sig, __sighandler_t __handler)
107      __THROW;
108 # endif
109 #endif /* __UCLIBC_HAS_OBSOLETE_SYSV_SIGNAL__ */
110
111 /* Set the handler for the signal SIG to HANDLER, returning the old
112    handler, or SIG_ERR on error.
113    By default `signal' has the BSD semantic.  */
114 __BEGIN_NAMESPACE_STD
115 #if defined __USE_BSD || !defined __UCLIBC_HAS_OBSOLETE_SYSV_SIGNAL__
116 extern __sighandler_t signal (int __sig, __sighandler_t __handler)
117      __THROW;
118 libc_hidden_proto(signal)
119 #else
120 /* Make sure the used `signal' implementation is the SVID version. */
121 # ifdef __REDIRECT_NTH
122 extern __sighandler_t __REDIRECT_NTH (signal,
123                                       (int __sig, __sighandler_t __handler),
124                                       __sysv_signal);
125 # else
126 #  define signal __sysv_signal
127 # endif
128 #endif
129 __END_NAMESPACE_STD
130
131 #if defined __USE_XOPEN && defined __UCLIBC_SUSV3_LEGACY__
132 /* The X/Open definition of `signal' conflicts with the BSD version.
133    So they defined another function `bsd_signal'.  */
134 extern __sighandler_t bsd_signal (int __sig, __sighandler_t __handler)
135      __THROW;
136 #endif
137
138 /* Send signal SIG to process number PID.  If PID is zero,
139    send SIG to all processes in the current process's process group.
140    If PID is < -1, send SIG to all processes in process group - PID.  */
141 #ifdef __USE_POSIX
142 extern int kill (__pid_t __pid, int __sig) __THROW;
143 libc_hidden_proto(kill)
144 #endif
145
146 #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
147 /* Send SIG to all processes in process group PGRP.
148    If PGRP is zero, send SIG to all processes in
149    the current process's process group.  */
150 extern int killpg (__pid_t __pgrp, int __sig) __THROW;
151 #endif
152
153 __BEGIN_NAMESPACE_STD
154 /* Raise signal SIG, i.e., send SIG to yourself.  */
155 extern int raise (int __sig) __THROW;
156 libc_hidden_proto(raise)
157 __END_NAMESPACE_STD
158
159 #if 0 /*def __USE_SVID*/
160 /* SVID names for the same things.  */
161 extern __sighandler_t ssignal (int __sig, __sighandler_t __handler)
162      __THROW;
163 extern int gsignal (int __sig) __THROW;
164 #endif /* Use SVID.  */
165
166 #ifdef __USE_MISC
167 /* Print a message describing the meaning of the given signal number.  */
168 extern void psignal (int __sig, __const char *__s);
169 #endif /* Use misc.  */
170
171 #ifdef __UCLIBC_SUSV4_LEGACY__
172 /* The `sigpause' function has two different interfaces.  The original
173    BSD definition defines the argument as a mask of the signal, while
174    the more modern interface in X/Open defines it as the signal
175    number.  We go with the BSD version unless the user explicitly
176    selects the X/Open version.
177
178    This function is a cancellation point and therefore not marked with
179    __THROW.  */
180 extern int __sigpause (int __sig_or_mask, int __is_sig);
181 libc_hidden_proto(__sigpause)
182
183 #ifdef __FAVOR_BSD
184 /* Set the mask of blocked signals to MASK,
185    wait for a signal to arrive, and then restore the mask.  */
186 extern int sigpause (int __mask) __THROW __attribute_deprecated__;
187 # define sigpause(mask) __sigpause ((mask), 0)
188 #else
189 # ifdef __USE_XOPEN
190 /* Remove a signal from the signal mask and suspend the process.  */
191 #  define sigpause(sig) __sigpause ((sig), 1)
192 # endif
193 #endif
194 #endif /* __UCLIBC_SUSV4_LEGACY__ */
195
196 #ifdef __USE_BSD
197 /* None of the following functions should be used anymore.  They are here
198    only for compatibility.  A single word (`int') is not guaranteed to be
199    enough to hold a complete signal mask and therefore these functions
200    simply do not work in many situations.  Use `sigprocmask' instead.  */
201
202 /* Compute mask for signal SIG.  */
203 # define sigmask(sig)   __sigmask(sig)
204
205 /* Block signals in MASK, returning the old mask.  */
206 extern int sigblock (int __mask) __THROW;
207 /* collides with libc_hidden_proto: __attribute_deprecated__; */
208 libc_hidden_proto(sigblock)
209
210 /* Set the mask of blocked signals to MASK, returning the old mask.  */
211 extern int sigsetmask (int __mask) __THROW;
212 /* collides with libc_hidden_proto: __attribute_deprecated__; */
213 libc_hidden_proto(sigsetmask)
214
215 /* Return currently selected signal mask.  */
216 extern int siggetmask (void) __THROW __attribute_deprecated__;
217 #endif /* Use BSD.  */
218
219
220 #ifdef __USE_GNU
221 typedef __sighandler_t sighandler_t;
222 #endif
223
224 /* 4.4 BSD uses the name `sig_t' for this.  */
225 #ifdef __USE_BSD
226 typedef __sighandler_t sig_t;
227 #endif
228
229 #ifdef __USE_POSIX
230
231 # ifdef __USE_POSIX199309
232 /* We need `struct timespec' later on.  */
233 #  define __need_timespec
234 #  include <time.h>
235
236 /* Get the `siginfo_t' type plus the needed symbols.  */
237 #  include <bits/siginfo.h>
238 # endif
239
240 /* Clear all signals from SET.  */
241 extern int sigemptyset (sigset_t *__set) __THROW __nonnull ((1));
242 libc_hidden_proto(sigemptyset)
243
244 /* Set all signals in SET.  */
245 extern int sigfillset (sigset_t *__set) __THROW __nonnull ((1));
246 libc_hidden_proto(sigfillset)
247
248 /* Add SIGNO to SET.  */
249 extern int sigaddset (sigset_t *__set, int __signo) __THROW __nonnull ((1));
250 libc_hidden_proto(sigaddset)
251
252 /* Remove SIGNO from SET.  */
253 extern int sigdelset (sigset_t *__set, int __signo) __THROW __nonnull ((1));
254 libc_hidden_proto(sigdelset)
255
256 /* Return 1 if SIGNO is in SET, 0 if not.  */
257 extern int sigismember (__const sigset_t *__set, int __signo)
258      __THROW __nonnull ((1));
259
260 # ifdef __USE_GNU
261 /* Return non-empty value is SET is not empty.  */
262 extern int sigisemptyset (__const sigset_t *__set) __THROW __nonnull ((1));
263
264 /* Build new signal set by combining the two inputs set using logical AND.  */
265 extern int sigandset (sigset_t *__set, __const sigset_t *__left,
266                       __const sigset_t *__right) __THROW __nonnull ((1, 2, 3));
267
268 /* Build new signal set by combining the two inputs set using logical OR.  */
269 extern int sigorset (sigset_t *__set, __const sigset_t *__left,
270                      __const sigset_t *__right) __THROW __nonnull ((1, 2, 3));
271 # endif /* GNU */
272
273 /* Get the system-specific definitions of `struct sigaction'
274    and the `SA_*' and `SIG_*'. constants.  */
275 # include <bits/sigaction.h>
276
277 /* Get and/or change the set of blocked signals.  */
278 extern int sigprocmask (int __how, __const sigset_t *__restrict __set,
279                         sigset_t *__restrict __oset) __THROW;
280 libc_hidden_proto(sigprocmask)
281
282 /* Change the set of blocked signals to SET,
283    wait until a signal arrives, and restore the set of blocked signals.
284
285    This function is a cancellation point and therefore not marked with
286    __THROW.  */
287 extern int sigsuspend (__const sigset_t *__set) __nonnull ((1));
288 libc_hidden_proto(sigsuspend)
289
290 /* Get and/or set the action for signal SIG.  */
291 extern int sigaction (int __sig, __const struct sigaction *__restrict __act,
292                       struct sigaction *__restrict __oact) __THROW;
293 #ifdef _LIBC
294 # if 0 /* this is in headers */
295 /* In uclibc, userspace struct sigaction is identical to
296  * "new" struct kernel_sigaction (one from the Linux 2.1.68 kernel).
297  * See sigaction.h
298  */
299 struct old_kernel_sigaction;
300 extern int __syscall_sigaction(int, __const struct old_kernel_sigaction *,
301         struct old_kernel_sigaction *) attribute_hidden;
302 # else /* this is how the function is built */
303 extern __typeof(sigaction) __syscall_sigaction attribute_hidden;
304 # endif
305 /* candidate for attribute_hidden, if NPTL would behave */
306 extern int __syscall_rt_sigaction(int, __const struct sigaction *,
307         struct sigaction *, size_t)
308 # ifndef __UCLIBC_HAS_THREADS_NATIVE__
309                 attribute_hidden
310 # endif
311         ;
312 extern __typeof(sigaction) __libc_sigaction;
313 libc_hidden_proto(sigaction)
314 #endif
315
316 /* Put in SET all signals that are blocked and waiting to be delivered.  */
317 extern int sigpending (sigset_t *__set) __THROW __nonnull ((1));
318
319
320 /* Select any of pending signals from SET or wait for any to arrive.
321
322    This function is a cancellation point and therefore not marked with
323    __THROW.  */
324 extern int sigwait (__const sigset_t *__restrict __set, int *__restrict __sig)
325      __nonnull ((1, 2));
326
327 # if defined __USE_POSIX199309 && defined __UCLIBC_HAS_REALTIME__
328 /* Select any of pending signals from SET and place information in INFO.
329
330    This function is a cancellation point and therefore not marked with
331    __THROW.  */
332 extern int sigwaitinfo (__const sigset_t *__restrict __set,
333                         siginfo_t *__restrict __info) __nonnull ((1));
334 #ifdef _LIBC
335 extern __typeof(sigwaitinfo) __sigwaitinfo attribute_hidden;
336 #endif
337
338 /* Select any of pending signals from SET and place information in INFO.
339    Wait the time specified by TIMEOUT if no signal is pending.
340
341    This function is a cancellation point and therefore not marked with
342    __THROW.  */
343 extern int sigtimedwait (__const sigset_t *__restrict __set,
344                          siginfo_t *__restrict __info,
345                          __const struct timespec *__restrict __timeout)
346      __nonnull ((1));
347 #ifdef _LIBC
348 extern __typeof(sigtimedwait) __sigtimedwait attribute_hidden;
349 #endif
350
351 /* Send signal SIG to the process PID.  Associate data in VAL with the
352    signal.  */
353 extern int sigqueue (__pid_t __pid, int __sig, __const union sigval __val)
354      __THROW;
355 # endif /* Use POSIX 199306.  */
356
357 #endif /* Use POSIX.  */
358
359 #ifdef __USE_BSD
360
361 # ifdef __UCLIBC_HAS_SYS_SIGLIST__
362 /* Names of the signals.  This variable exists only for compatibility.
363    Use `strsignal' instead (see <string.h>).  */
364 #  define _sys_siglist sys_siglist
365 extern __const char *__const sys_siglist[_NSIG];
366 # endif
367
368 #ifndef __UCLIBC_STRICT_HEADERS__
369 /* Structure passed to `sigvec'.  */
370 struct sigvec
371   {
372     __sighandler_t sv_handler;  /* Signal handler.  */
373     int sv_mask;                /* Mask of signals to be blocked.  */
374
375     int sv_flags;               /* Flags (see below).  */
376 # define sv_onstack     sv_flags /* 4.2 BSD compatibility.  */
377   };
378
379 /* Bits in `sv_flags'.  */
380 # define SV_ONSTACK     (1 << 0)/* Take the signal on the signal stack.  */
381 # define SV_INTERRUPT   (1 << 1)/* Do not restart system calls.  */
382 # define SV_RESETHAND   (1 << 2)/* Reset handler to SIG_DFL on receipt.  */
383 #endif
384
385
386 #if 0
387 /* If VEC is non-NULL, set the handler for SIG to the `sv_handler' member
388    of VEC.  The signals in `sv_mask' will be blocked while the handler runs.
389    If the SV_RESETHAND bit is set in `sv_flags', the handler for SIG will be
390    reset to SIG_DFL before `sv_handler' is entered.  If OVEC is non-NULL,
391    it is filled in with the old information for SIG.  */
392 extern int sigvec (int __sig, __const struct sigvec *__vec,
393                    struct sigvec *__ovec) __THROW;
394 #endif
395
396
397 /* Get machine-dependent `struct sigcontext' and signal subcodes.  */
398 # include <bits/sigcontext.h>
399
400 /* Restore the state saved in SCP.  */
401 extern int sigreturn (struct sigcontext *__scp) __THROW;
402
403 #endif /*  use BSD.  */
404
405
406 #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED
407
408 # ifdef __UCLIBC_SUSV4_LEGACY__
409 /* If INTERRUPT is nonzero, make signal SIG interrupt system calls
410    (causing them to fail with EINTR); if INTERRUPT is zero, make system
411    calls be restarted after signal SIG.  */
412 extern int siginterrupt (int __sig, int __interrupt) __THROW;
413 # endif
414
415 # include <bits/sigstack.h>
416 # ifdef __USE_XOPEN
417 /* This will define `ucontext_t' and `mcontext_t'.  */
418 /* SuSv4 obsoleted include/ucontext.h */
419 #  include <sys/ucontext.h>
420 # endif
421
422 # if 0
423 /* Run signals handlers on the stack specified by SS (if not NULL).
424    If OSS is not NULL, it is filled in with the old signal stack status.
425    This interface is obsolete and on many platform not implemented.  */
426 extern int sigstack (struct sigstack *__ss, struct sigstack *__oss)
427      __THROW __attribute_deprecated__;
428 # endif
429
430 /* Alternate signal handler stack interface.
431    This interface should always be preferred over `sigstack'.  */
432 extern int sigaltstack (__const struct sigaltstack *__restrict __ss,
433                         struct sigaltstack *__restrict __oss) __THROW;
434
435 #endif /* use BSD or X/Open Unix.  */
436
437 #if defined __USE_XOPEN_EXTENDED && defined __UCLIBC_HAS_OBSOLETE_BSD_SIGNAL__
438 /* Simplified interface for signal management.  */
439
440 /* Add SIG to the calling process' signal mask.  */
441 extern int sighold (int __sig) __THROW;
442
443 /* Remove SIG from the calling process' signal mask.  */
444 extern int sigrelse (int __sig) __THROW;
445
446 /* Set the disposition of SIG to SIG_IGN.  */
447 extern int sigignore (int __sig) __THROW;
448
449 /* Set the disposition of SIG.  */
450 extern __sighandler_t sigset (int __sig, __sighandler_t __disp) __THROW;
451 #endif
452
453 #if defined __UCLIBC_HAS_THREADS__ && (defined __USE_POSIX199506 || defined __USE_UNIX98)
454 /* Some of the functions for handling signals in threaded programs must
455    be defined here.  */
456 # include <bits/pthreadtypes.h>
457 # include <bits/sigthread.h>
458 #endif
459
460 /* The following functions are used internally in the C library and in
461    other code which need deep insights.  */
462
463 /* Return number of available real-time signal with highest priority.  */
464 extern int __libc_current_sigrtmin (void) __THROW;
465 /* Return number of available real-time signal with lowest priority.  */
466 extern int __libc_current_sigrtmax (void) __THROW;
467
468 #endif /* signal.h  */
469
470 __END_DECLS
471
472 #endif /* not signal.h */