1sigprocmask(2)                System Calls Manual               sigprocmask(2)
2
3
4

NAME

6       sigprocmask, rt_sigprocmask - examine and change blocked signals
7

LIBRARY

9       Standard C library (libc, -lc)
10

SYNOPSIS

12       #include <signal.h>
13
14       /* Prototype for the glibc wrapper function */
15       int sigprocmask(int how, const sigset_t *_Nullable restrict set,
16                                  sigset_t *_Nullable restrict oldset);
17
18       #include <signal.h>           /* Definition of SIG_* constants */
19       #include <sys/syscall.h>      /* Definition of SYS_* constants */
20       #include <unistd.h>
21
22       /* Prototype for the underlying system call */
23       int syscall(SYS_rt_sigprocmask, int how,
24                                  const kernel_sigset_t *_Nullable set,
25                                  kernel_sigset_t *_Nullable oldset,
26                                  size_t sigsetsize);
27
28       /* Prototype for the legacy system call */
29       [[deprecated]] int syscall(SYS_sigprocmask, int how,
30                                  const old_kernel_sigset_t *_Nullable set,
31                                  old_kernel_sigset_t *_Nullable oldset);
32
33   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
34
35       sigprocmask():
36           _POSIX_C_SOURCE
37

DESCRIPTION

39       sigprocmask()  is  used  to  fetch and/or change the signal mask of the
40       calling thread.  The signal mask is the set of signals  whose  delivery
41       is  currently  blocked  for the caller (see also signal(7) for more de‐
42       tails).
43
44       The behavior of the call is dependent on the value of how, as follows.
45
46       SIG_BLOCK
47              The set of blocked signals is the union of the current  set  and
48              the set argument.
49
50       SIG_UNBLOCK
51              The  signals  in set are removed from the current set of blocked
52              signals.  It is permissible to attempt to unblock a signal which
53              is not blocked.
54
55       SIG_SETMASK
56              The set of blocked signals is set to the argument set.
57
58       If  oldset is non-NULL, the previous value of the signal mask is stored
59       in oldset.
60
61       If set is NULL, then the signal mask is unchanged  (i.e.,  how  is  ig‐
62       nored),  but  the  current value of the signal mask is nevertheless re‐
63       turned in oldset (if it is not NULL).
64
65       A set of functions for  modifying  and  inspecting  variables  of  type
66       sigset_t ("signal sets") is described in sigsetops(3).
67
68       The use of sigprocmask() is unspecified in a multithreaded process; see
69       pthread_sigmask(3).
70

RETURN VALUE

72       sigprocmask() returns 0 on success.  On failure, -1 is returned and er‐
73       rno is set to indicate the error.
74

ERRORS

76       EFAULT The  set  or  oldset argument points outside the process's allo‐
77              cated address space.
78
79       EINVAL Either the value specified in how was invalid or the kernel does
80              not support the size passed in sigsetsize.
81

VERSIONS

83   C library/kernel differences
84       The  kernel's  definition of sigset_t differs in size from that used by
85       the C library.  In this manual page, the former is referred to as  ker‐
86       nel_sigset_t (it is nevertheless named sigset_t in the kernel sources).
87
88       The  glibc wrapper function for sigprocmask() silently ignores attempts
89       to block the two real-time signals that are used internally by the NPTL
90       threading implementation.  See nptl(7) for details.
91
92       The  original Linux system call was named sigprocmask().  However, with
93       the addition of real-time signals in Linux 2.2, the fixed-size,  32-bit
94       sigset_t  (referred to as old_kernel_sigset_t in this manual page) type
95       supported by that system call was no longer fit  for  purpose.   Conse‐
96       quently,  a  new system call, rt_sigprocmask(), was added to support an
97       enlarged sigset_t type (referred to as kernel_sigset_t in  this  manual
98       page).  The new system call takes a fourth argument, size_t sigsetsize,
99       which specifies the size in bytes of the signal sets in set and oldset.
100       This  argument  is currently required to have a fixed architecture spe‐
101       cific value (equal to sizeof(kernel_sigset_t)).
102
103       The glibc sigprocmask() wrapper function hides these details  from  us,
104       transparently calling rt_sigprocmask() when the kernel provides it.
105

STANDARDS

107       POSIX.1-2008.
108

HISTORY

110       POSIX.1-2001.
111

NOTES

113       It  is not possible to block SIGKILL or SIGSTOP.  Attempts to do so are
114       silently ignored.
115
116       Each of the threads in a process has its own signal mask.
117
118       A child created via fork(2) inherits a  copy  of  its  parent's  signal
119       mask; the signal mask is preserved across execve(2).
120
121       If  SIGBUS,  SIGFPE,  SIGILL,  or  SIGSEGV are generated while they are
122       blocked, the result is undefined, unless the signal  was  generated  by
123       kill(2), sigqueue(3), or raise(3).
124
125       See sigsetops(3) for details on manipulating signal sets.
126
127       Note  that it is permissible (although not very useful) to specify both
128       set and oldset as NULL.
129

SEE ALSO

131       kill(2),  pause(2),  sigaction(2),  signal(2),  sigpending(2),  sigsus‐
132       pend(2), pthread_sigmask(3), sigqueue(3), sigsetops(3), signal(7)
133
134
135
136Linux man-pages 6.04              2023-03-30                    sigprocmask(2)
Impressum