1 /* signals.h -- header to include system dependent signal definitions.
2 $Id: signals.h,v 1.5 2007/07/01 21:20:31 karl Exp $
4 Copyright (C) 1993, 1994, 1995, 1997, 2002, 2004, 2007
5 Free Software Foundation, Inc.
7 This program is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 Originally written by Brian Fox (bfox@ai.mit.edu). */
22 #ifndef INFO_SIGNALS_H
23 #define INFO_SIGNALS_H
25 #include <sys/types.h>
28 /* For sysV68 --phdm@info.ucl.ac.be. */
29 #if !defined (SIGCHLD) && defined (SIGCLD)
30 #define SIGCHLD SIGCLD
33 #if !defined (HAVE_SIGPROCMASK) && !defined (sigmask)
34 # define sigmask(x) (1 << ((x)-1))
35 #endif /* !HAVE_SIGPROCMASK && !sigmask */
37 /* Without SA_NOCLDSTOP, sigset_t might end up being undefined even
38 though we have sigprocmask, on older systems, according to Nelson
39 Beebe. The test is from coreutils/sort.c, via Paul Eggert. */
40 #if !defined (HAVE_SIGPROCMASK) || !defined (SA_NOCLDSTOP)
41 # if !defined (SIG_BLOCK)
42 # define SIG_UNBLOCK 1
44 # define SIG_SETMASK 3
45 # endif /* SIG_BLOCK */
47 /* Type of a signal set. */
50 /* Make SET have no signals in it. */
51 # define sigemptyset(set) (*(set) = (sigset_t)0x0)
53 /* Make SET have the full range of signal specifications possible. */
54 # define sigfillset(set) (*(set) = (sigset_t)0xffffffffff)
56 /* Add SIG to the contents of SET. */
57 # define sigaddset(set, sig) *(set) |= sigmask (sig)
59 /* Delete SIG from the contents of SET. */
60 # define sigdelset(set, sig) *(set) &= ~(sigmask (sig))
62 /* Tell if SET contains SIG. */
63 # define sigismember(set, sig) (*(set) & (sigmask (sig)))
65 /* Suspend the process until the reception of one of the signals
66 not present in SET. */
67 # define sigsuspend(set) sigpause (*(set))
68 #endif /* !HAVE_SIGPROCMASK */
70 #if defined (HAVE_SIGPROCMASK) || defined (HAVE_SIGSETMASK)
71 /* These definitions are used both in POSIX and non-POSIX implementations. */
73 #define BLOCK_SIGNAL(sig) \
75 sigset_t nvar, ovar; \
76 sigemptyset (&nvar); \
77 sigemptyset (&ovar); \
78 sigaddset (&nvar, sig); \
79 sigprocmask (SIG_BLOCK, &nvar, &ovar); \
82 #define UNBLOCK_SIGNAL(sig) \
84 sigset_t nvar, ovar; \
85 sigemptyset (&ovar); \
86 sigemptyset (&nvar); \
87 sigaddset (&nvar, sig); \
88 sigprocmask (SIG_UNBLOCK, &nvar, &ovar); \
91 #else /* !HAVE_SIGPROCMASK && !HAVE_SIGSETMASK */
92 # define BLOCK_SIGNAL(sig)
93 # define UNBLOCK_SIGNAL(sig)
94 #endif /* !HAVE_SIGPROCMASK && !HAVE_SIGSETMASK */
96 #endif /* not INFO_SIGNALS_H */