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 (date) "Linux man-pages (unreleased)"
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 *_Nullable restrict " set ,
21 .BI " sigset_t *_Nullable 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 ,
29 .BI " const kernel_sigset_t *_Nullable " set ,
30 .BI " kernel_sigset_t *_Nullable " oldset ,
31 .BI " size_t " sigsetsize );
33 /* Prototype for the legacy system call */
34 .BI "[[deprecated]] int syscall(SYS_sigprocmask, int " how ,
35 .BI " const old_kernel_sigset_t *_Nullable " set ,
36 .BI " old_kernel_sigset_t *_Nullable " oldset );
40 Feature Test Macro Requirements for glibc (see
41 .BR feature_test_macros (7)):
50 is used to fetch and/or change the signal mask of the calling thread.
51 The signal mask is the set of signals whose delivery is currently
52 blocked for the caller
57 The behavior of the call is dependent on the value of
62 The set of blocked signals is the union of the current set and the
69 are removed from the current set of blocked signals.
70 It is permissible to attempt to unblock a signal which is not blocked.
73 The set of blocked signals is set to the argument
78 is non-NULL, the previous value of the signal mask is stored in
83 is NULL, then the signal mask is unchanged (i.e.,
86 but the current value of the signal mask is nevertheless returned in
90 A set of functions for modifying and inspecting variables of type
92 ("signal sets") is described in
97 is unspecified in a multithreaded process; see
98 .BR pthread_sigmask (3).
101 returns 0 on success.
102 On failure, \-1 is returned and
104 is set to indicate the error.
112 argument points outside the process's allocated address space.
115 Either the value specified in
117 was invalid or the kernel does not support the size passed in
120 .SS C library/kernel differences
121 The kernel's definition of
123 differs in size from that used
125 In this manual page, the former is referred to as
127 (it is nevertheless named
129 in the kernel sources).
131 The glibc wrapper function for
133 silently ignores attempts to block the two real-time signals that
134 are used internally by the NPTL threading implementation.
139 The original Linux system call was named
141 However, with the addition of real-time signals in Linux 2.2,
142 the fixed-size, 32-bit
145 .I old_kernel_sigset_t
147 type supported by that system call was no longer fit for purpose.
148 Consequently, a new system call,
149 .BR rt_sigprocmask (),
150 was added to support an enlarged
155 in this manual page).
156 The new system call takes a fourth argument,
157 .IR "size_t sigsetsize" ,
158 which specifies the size in bytes of the signal sets in
162 This argument is currently required to have a fixed architecture specific value
164 .IR sizeof(kernel_sigset_t) ).
165 .\" sizeof(kernel_sigset_t) == _NSIG / 8,
166 .\" which equals to 8 on most architectures, but e.g. on MIPS it's 16.
170 wrapper function hides these details from us, transparently calling
171 .BR rt_sigprocmask ()
172 when the kernel provides it.
179 It is not possible to block
180 .BR SIGKILL " or " SIGSTOP .
181 Attempts to do so are silently ignored.
183 Each of the threads in a process has its own signal mask.
187 inherits a copy of its parent's signal mask;
188 the signal mask is preserved across
198 while they are blocked, the result is undefined,
199 unless the signal was generated by
207 for details on manipulating signal sets.
209 Note that it is permissible (although not very useful) to specify both
221 .BR pthread_sigmask (3),