3 /* signals.h -- header to include system dependent signal definitions.
4 Id: signals.h,v 1.2 2004/04/11 17:56:46 karl Exp
6 Copyright (C) 1993, 1994, 1995, 1997, 2002, 2004 Free Software Foundation, Inc.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 Originally written by Brian Fox (bfox@ai.mit.edu). */
24 #ifndef INFO_SIGNALS_H
25 #define INFO_SIGNALS_H
27 #include <sys/types.h>
30 /* For sysV68 --phdm@info.ucl.ac.be. */
31 #if !defined (SIGCHLD) && defined (SIGCLD)
32 #define SIGCHLD SIGCLD
35 #if !defined (HAVE_SIGPROCMASK) && !defined (sigmask)
36 # define sigmask(x) (1 << ((x)-1))
37 #endif /* !HAVE_SIGPROCMASK && !sigmask */
39 /* Without SA_NOCLDSTOP, sigset_t might end up being undefined even
40 though we have sigprocmask, on older systems, according to Nelson
41 Beebe. The test is from coreutils/sort.c, via Paul Eggert. */
42 #if !defined (HAVE_SIGPROCMASK) || !defined (SA_NOCLDSTOP)
43 # if !defined (SIG_BLOCK)
44 # define SIG_UNBLOCK 1
46 # define SIG_SETMASK 3
47 # endif /* SIG_BLOCK */
49 /* Type of a signal set. */
52 /* Make SET have no signals in it. */
53 # define sigemptyset(set) (*(set) = (sigset_t)0x0)
55 /* Make SET have the full range of signal specifications possible. */
56 # define sigfillset(set) (*(set) = (sigset_t)0xffffffffff)
58 /* Add SIG to the contents of SET. */
59 # define sigaddset(set, sig) *(set) |= sigmask (sig)
61 /* Delete SIG from the contents of SET. */
62 # define sigdelset(set, sig) *(set) &= ~(sigmask (sig))
64 /* Tell if SET contains SIG. */
65 # define sigismember(set, sig) (*(set) & (sigmask (sig)))
67 /* Suspend the process until the reception of one of the signals
68 not present in SET. */
69 # define sigsuspend(set) sigpause (*(set))
70 #endif /* !HAVE_SIGPROCMASK */
72 #if defined (HAVE_SIGPROCMASK) || defined (HAVE_SIGSETMASK)
73 /* These definitions are used both in POSIX and non-POSIX implementations. */
75 #define BLOCK_SIGNAL(sig) \
77 sigset_t nvar, ovar; \
78 sigemptyset (&nvar); \
79 sigemptyset (&ovar); \
80 sigaddset (&nvar, sig); \
81 sigprocmask (SIG_BLOCK, &nvar, &ovar); \
84 #define UNBLOCK_SIGNAL(sig) \
86 sigset_t nvar, ovar; \
87 sigemptyset (&ovar); \
88 sigemptyset (&nvar); \
89 sigaddset (&nvar, sig); \
90 sigprocmask (SIG_UNBLOCK, &nvar, &ovar); \
93 #else /* !HAVE_SIGPROCMASK && !HAVE_SIGSETMASK */
94 # define BLOCK_SIGNAL(sig)
95 # define UNBLOCK_SIGNAL(sig)
96 #endif /* !HAVE_SIGPROCMASK && !HAVE_SIGSETMASK */
98 #endif /* not INFO_SIGNALS_H */