1 .\" Copyright (c) 2005 Michael Kerrisk
2 .\" based on earlier work by faith@cs.unc.edu and
3 .\" Mike Battersby <mib@deakin.edu.au>
5 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
7 .\" 2005-09-15, mtk, Created new page by splitting off from sigaction.2
9 .TH SIGPROCMASK 2 2021-03-22 "Linux" "Linux Programmer's Manual"
11 sigprocmask, rt_sigprocmask \- examine and change blocked signals
14 .RI ( libc ", " \-lc )
16 .B #include <signal.h>
19 /* Prototype for the glibc wrapper function */
20 .BI "int sigprocmask(int " how ", const sigset_t *restrict " set ,
21 .BI " sigset_t *restrict " oldset );
23 .BR "#include <signal.h>" " /* Definition of " SIG_* " constants */"
24 .BR "#include <sys/syscall.h>" " /* Definition of " SYS_* " constants */"
25 .B #include <unistd.h>
27 /* Prototype for the underlying system call */
28 .BI "int syscall(SYS_rt_sigprocmask, int " how ", const kernel_sigset_t *" set ,
29 .BI " kernel_sigset_t *" oldset ", size_t " sigsetsize );
31 /* Prototype for the legacy system call (deprecated) */
32 .BI "int syscall(SYS_sigprocmask, int " how ", const old_kernel_sigset_t *" set ,
33 .BI " old_kernel_sigset_t *" oldset );
37 Feature Test Macro Requirements for glibc (see
38 .BR feature_test_macros (7)):
47 is used to fetch and/or change the signal mask of the calling thread.
48 The signal mask is the set of signals whose delivery is currently
49 blocked for the caller
54 The behavior of the call is dependent on the value of
59 The set of blocked signals is the union of the current set and the
66 are removed from the current set of blocked signals.
67 It is permissible to attempt to unblock a signal which is not blocked.
70 The set of blocked signals is set to the argument
75 is non-NULL, the previous value of the signal mask is stored in
80 is NULL, then the signal mask is unchanged (i.e.,
83 but the current value of the signal mask is nevertheless returned in
87 A set of functions for modifying and inspecting variables of type
89 ("signal sets") is described in
94 is unspecified in a multithreaded process; see
95 .BR pthread_sigmask (3).
99 On failure, \-1 is returned and
101 is set to indicate the error.
109 argument points outside the process's allocated address space.
112 Either the value specified in
114 was invalid or the kernel does not support the size passed in
117 POSIX.1-2001, POSIX.1-2008.
119 It is not possible to block
120 .BR SIGKILL " or " SIGSTOP .
121 Attempts to do so are silently ignored.
123 Each of the threads in a process has its own signal mask.
127 inherits a copy of its parent's signal mask;
128 the signal mask is preserved across
138 while they are blocked, the result is undefined,
139 unless the signal was generated by
147 for details on manipulating signal sets.
149 Note that it is permissible (although not very useful) to specify both
155 .SS C library/kernel differences
156 The kernel's definition of
158 differs in size from that used
160 In this manual page, the former is referred to as
162 (it is nevertheless named
164 in the kernel sources).
166 The glibc wrapper function for
168 silently ignores attempts to block the two real-time signals that
169 are used internally by the NPTL threading implementation.
174 The original Linux system call was named
176 However, with the addition of real-time signals in Linux 2.2,
177 the fixed-size, 32-bit
180 .IR old_kernel_sigset_t
182 type supported by that system call was no longer fit for purpose.
183 Consequently, a new system call,
184 .BR rt_sigprocmask (),
185 was added to support an enlarged
190 in this manual page).
191 The new system call takes a fourth argument,
192 .IR "size_t sigsetsize" ,
193 which specifies the size in bytes of the signal sets in
197 This argument is currently required to have a fixed architecture specific value
199 .IR sizeof(kernel_sigset_t) ).
200 .\" sizeof(kernel_sigset_t) == _NSIG / 8,
201 .\" which equals to 8 on most architectures, but e.g. on MIPS it's 16.
205 wrapper function hides these details from us, transparently calling
206 .BR rt_sigprocmask ()
207 when the kernel provides it.
216 .BR pthread_sigmask (3),