f88351f477f12302652bef7f4e55153947aeeaeb
[gnulib.git] / lib / sigprocmask.h
1 /* POSIX compatible signal blocking.
2    Copyright (C) 2006 Free Software Foundation, Inc.
3    Written by Bruno Haible <bruno@clisp.org>, 2006.
4
5    This program is free software; you can redistribute it and/or modify
6    it under the terms of the GNU General Public License as published by
7    the Free Software Foundation; either version 2, or (at your option)
8    any later version.
9
10    This program is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13    GNU General Public License for more details.
14
15    You should have received a copy of the GNU General Public License
16    along with this program; if not, write to the Free Software Foundation,
17    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
18
19 #include <signal.h>
20
21 #if ! HAVE_POSIX_SIGNALBLOCKING
22
23 # include "verify.h"
24
25 /* Maximum signal number + 1.  */
26 # ifndef NSIG
27 #  define NSIG 32
28 # endif
29
30 /* This code supports only 32 signals.  */
31 verify (NSIG <= 32);
32
33 /* A set or mask of signals.  */
34 typedef unsigned int sigset_t;
35
36 /* Test whether a given signal is contained in a signal set.  */
37 extern int sigismember (const sigset_t *set, int sig);
38
39 /* Initialize a signal set to the empty set.  */
40 extern int sigemptyset (sigset_t *set);
41
42 /* Add a signal to a signal set.  */
43 extern int sigaddset (sigset_t *set, int sig);
44
45 /* Remove a signal from a signal set.  */
46 extern int sigdelset (sigset_t *set, int sig);
47
48 /* Fill a signal set with all possible signals.  */
49 extern int sigfillset (sigset_t *set);
50
51 /* Return the set of those blocked signals that are pending.  */
52 extern int sigpending (sigset_t *set);
53
54 /* If OLD_SET is not NULL, put the current set of blocked signals in *OLD_SET.
55    Then, if SET is not NULL, affect the current set of blocked signals by
56    combining it with *SET as indicated in OPERATION.
57    In this implementation, you are not allowed to change a signal handler
58    while the signal is blocked.  */
59 # define SIG_BLOCK   0  /* blocked_set = blocked_set | *set; */
60 # define SIG_SETMASK 1  /* blocked_set = *set; */
61 # define SIG_UNBLOCK 2  /* blocked_set = blocked_set & ~*set; */
62 extern int sigprocmask (int operation, const sigset_t *set, sigset_t *old_set);
63
64 #endif