1 | /* signals.h -- header to include system dependent signal definitions.
|
---|
2 | $Id: signals.h,v 1.2 2004/04/11 17:56:46 karl Exp $
|
---|
3 |
|
---|
4 | Copyright (C) 1993, 1994, 1995, 1997, 2002, 2004 Free Software Foundation, Inc.
|
---|
5 |
|
---|
6 | This program is free software; you can redistribute it and/or modify
|
---|
7 | it under the terms of the GNU General Public License as published by
|
---|
8 | the Free Software Foundation; either version 2, or (at your option)
|
---|
9 | any later version.
|
---|
10 |
|
---|
11 | This program is distributed in the hope that it will be useful,
|
---|
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
14 | GNU General Public License for more details.
|
---|
15 |
|
---|
16 | You should have received a copy of the GNU General Public License
|
---|
17 | along with this program; if not, write to the Free Software
|
---|
18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
---|
19 |
|
---|
20 | Originally written by Brian Fox (bfox@ai.mit.edu). */
|
---|
21 |
|
---|
22 | #ifndef INFO_SIGNALS_H
|
---|
23 | #define INFO_SIGNALS_H
|
---|
24 |
|
---|
25 | #include <sys/types.h>
|
---|
26 | #include <signal.h>
|
---|
27 |
|
---|
28 | /* For sysV68 --phdm@info.ucl.ac.be. */
|
---|
29 | #if !defined (SIGCHLD) && defined (SIGCLD)
|
---|
30 | #define SIGCHLD SIGCLD
|
---|
31 | #endif
|
---|
32 |
|
---|
33 | #if !defined (HAVE_SIGPROCMASK) && !defined (sigmask)
|
---|
34 | # define sigmask(x) (1 << ((x)-1))
|
---|
35 | #endif /* !HAVE_SIGPROCMASK && !sigmask */
|
---|
36 |
|
---|
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
|
---|
43 | # define SIG_BLOCK 2
|
---|
44 | # define SIG_SETMASK 3
|
---|
45 | # endif /* SIG_BLOCK */
|
---|
46 |
|
---|
47 | /* Type of a signal set. */
|
---|
48 | # define sigset_t int
|
---|
49 |
|
---|
50 | /* Make SET have no signals in it. */
|
---|
51 | # define sigemptyset(set) (*(set) = (sigset_t)0x0)
|
---|
52 |
|
---|
53 | /* Make SET have the full range of signal specifications possible. */
|
---|
54 | # define sigfillset(set) (*(set) = (sigset_t)0xffffffffff)
|
---|
55 |
|
---|
56 | /* Add SIG to the contents of SET. */
|
---|
57 | # define sigaddset(set, sig) *(set) |= sigmask (sig)
|
---|
58 |
|
---|
59 | /* Delete SIG from the contents of SET. */
|
---|
60 | # define sigdelset(set, sig) *(set) &= ~(sigmask (sig))
|
---|
61 |
|
---|
62 | /* Tell if SET contains SIG. */
|
---|
63 | # define sigismember(set, sig) (*(set) & (sigmask (sig)))
|
---|
64 |
|
---|
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 */
|
---|
69 |
|
---|
70 | #if defined (HAVE_SIGPROCMASK) || defined (HAVE_SIGSETMASK)
|
---|
71 | /* These definitions are used both in POSIX and non-POSIX implementations. */
|
---|
72 |
|
---|
73 | #define BLOCK_SIGNAL(sig) \
|
---|
74 | do { \
|
---|
75 | sigset_t nvar, ovar; \
|
---|
76 | sigemptyset (&nvar); \
|
---|
77 | sigemptyset (&ovar); \
|
---|
78 | sigaddset (&nvar, sig); \
|
---|
79 | sigprocmask (SIG_BLOCK, &nvar, &ovar); \
|
---|
80 | } while (0)
|
---|
81 |
|
---|
82 | #define UNBLOCK_SIGNAL(sig) \
|
---|
83 | do { \
|
---|
84 | sigset_t nvar, ovar; \
|
---|
85 | sigemptyset (&ovar); \
|
---|
86 | sigemptyset (&nvar); \
|
---|
87 | sigaddset (&nvar, sig); \
|
---|
88 | sigprocmask (SIG_UNBLOCK, &nvar, &ovar); \
|
---|
89 | } while (0)
|
---|
90 |
|
---|
91 | #else /* !HAVE_SIGPROCMASK && !HAVE_SIGSETMASK */
|
---|
92 | # define BLOCK_SIGNAL(sig)
|
---|
93 | # define UNBLOCK_SIGNAL(sig)
|
---|
94 | #endif /* !HAVE_SIGPROCMASK && !HAVE_SIGSETMASK */
|
---|
95 |
|
---|
96 | #endif /* not INFO_SIGNALS_H */
|
---|