Debian Codegraph @

upstream/debian-unstable/man2/sigprocmask.2

raw
1 .\" Copyright 2005, Michael Kerrisk <[email protected]>
2 .\" Copyright, the authors of the Linux man-pages project
3 .\"
4 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
5 .\"
6 .TH sigprocmask 2 2026-02-08 "Linux man-pages 6.18"
7 .SH NAME
8 sigprocmask, rt_sigprocmask \- examine and change blocked signals
9 .SH LIBRARY
10 Standard C library
11 .RI ( libc ,\~ \-lc )
12 .SH SYNOPSIS
13 .B #include <signal.h>
14 .P
15 .nf
16 /* Prototype for the glibc wrapper function */
17 .BI "int sigprocmask(int " how ", const sigset_t *_Nullable restrict " set ,
18 .BI " sigset_t *_Nullable restrict " oldset );
19 .P
20 .BR "#include <signal.h>" " /* Definition of " SIG_* " constants */"
21 .BR "#include <sys/syscall.h>" " /* Definition of " SYS_* " constants */"
22 .B #include <unistd.h>
23 .P
24 /* Prototype for the underlying system call */
25 .BI "int syscall(SYS_rt_sigprocmask, int " how ,
26 .BI " const kernel_sigset_t *_Nullable " set ,
27 .BI " kernel_sigset_t *_Nullable " oldset ,
28 .BI " size_t " sigsetsize );
29 .P
30 /* Prototype for the legacy system call */
31 .BI "[[deprecated]] int syscall(SYS_sigprocmask, int " how ,
32 .BI " const old_kernel_sigset_t *_Nullable " set ,
33 .BI " old_kernel_sigset_t *_Nullable " oldset );
34 .fi
35 .P
36 .RS -4
37 Feature Test Macro Requirements for glibc (see
38 .BR feature_test_macros (7)):
39 .RE
40 .P
41 .BR sigprocmask ():
42 .nf
43 _POSIX_C_SOURCE
44 .fi
45 .SH DESCRIPTION
46 .BR sigprocmask ()
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
50 (see also
51 .BR signal (7)
52 for more details).
53 .P
54 The behavior of the call is dependent on the value of
55 .IR how ,
56 as follows.
57 .TP
58 .B SIG_BLOCK
59 The set of blocked signals is the union of the current set and the
60 .I set
61 argument.
62 .TP
63 .B SIG_UNBLOCK
64 The signals in
65 .I set
66 are removed from the current set of blocked signals.
67 It is permissible to attempt to unblock a signal which is not blocked.
68 .TP
69 .B SIG_SETMASK
70 The set of blocked signals is set to the argument
71 .IR set .
72 .P
73 If
74 .I oldset
75 is non-NULL, the previous value of the signal mask is stored in
76 .IR oldset .
77 .P
78 If
79 .I set
80 is NULL, then the signal mask is unchanged (i.e.,
81 .I how
82 is ignored),
83 but the current value of the signal mask is nevertheless returned in
84 .I oldset
85 (if it is not NULL).
86 .P
87 A set of functions for modifying and inspecting variables of type
88 .I sigset_t
89 ("signal sets") is described in
90 .BR sigsetops (3).
91 .P
92 The use of
93 .BR sigprocmask ()
94 is unspecified in a multithreaded process;
95 see
96 .BR pthread_sigmask (3).
97 .SH RETURN VALUE
98 .BR sigprocmask ()
99 returns 0 on success.
100 On failure, \-1 is returned and
101 .I errno
102 is set to indicate the error.
103 .SH ERRORS
104 .TP
105 .B EFAULT
106 The
107 .I set
108 or
109 .I oldset
110 argument points outside the process's allocated address space.
111 .TP
112 .B EINVAL
113 Either the value specified in
114 .I how
115 was invalid or the kernel does not support the size passed in
116 .I sigsetsize.
117 .SH VERSIONS
118 .SS C library/kernel differences
119 The kernel's definition of
120 .I sigset_t
121 differs in size from that used
122 by the C library.
123 In this manual page, the former is referred to as
124 .I kernel_sigset_t
125 (it is nevertheless named
126 .I sigset_t
127 in the kernel sources).
128 .P
129 The glibc wrapper function for
130 .BR sigprocmask ()
131 silently ignores attempts to block the two real-time signals that
132 are used internally by the NPTL threading implementation.
133 See
134 .BR nptl (7)
135 for details.
136 .P
137 The original Linux system call was named
138 .BR sigprocmask ().
139 However, with the addition of real-time signals in Linux 2.2,
140 the fixed-size, 32-bit
141 .I sigset_t
142 (referred to as
143 .I old_kernel_sigset_t
144 in this manual page)
145 type supported by that system call was no longer fit for purpose.
146 Consequently, a new system call,
147 .BR rt_sigprocmask (),
148 was added to support an enlarged
149 .I sigset_t
150 type
151 (referred to as
152 .I kernel_sigset_t
153 in this manual page).
154 The new system call takes a fourth argument,
155 .IR "size_t sigsetsize" ,
156 which specifies the size in bytes of the signal sets in
157 .I set
158 and
159 .IR oldset .
160 This argument is currently required to have a fixed architecture specific value
161 (equal to
162 .IR sizeof(kernel_sigset_t) ).
163 .\" sizeof(kernel_sigset_t) == _NSIG / 8,
164 .\" which equals to 8 on most architectures, but e.g., on MIPS it's 16.
165 .P
166 The glibc
167 .BR sigprocmask ()
168 wrapper function hides these details from us, transparently calling
169 .BR rt_sigprocmask ()
170 when the kernel provides it.
171 .\"
172 .SH STANDARDS
173 POSIX.1-2024.
174 .SH HISTORY
175 POSIX.1-2001.
176 .SH NOTES
177 It is not possible to block
178 .BR SIGKILL " or " SIGSTOP .
179 Attempts to do so are silently ignored.
180 .P
181 Each of the threads in a process has its own signal mask.
182 .P
183 A child created via
184 .BR fork (2)
185 inherits a copy of its parent's signal mask;
186 the signal mask is preserved across
187 .BR execve (2).
188 .P
189 If
190 .BR SIGBUS ,
191 .BR SIGFPE ,
192 .BR SIGILL ,
193 or
194 .B SIGSEGV
195 are generated
196 while they are blocked, the result is undefined,
197 unless the signal was generated by
198 .BR kill (2),
199 .BR sigqueue (3),
200 or
201 .BR raise (3).
202 .P
203 See
204 .BR sigsetops (3)
205 for details on manipulating signal sets.
206 .P
207 Note that it is permissible (although not very useful) to specify both
208 .I set
209 and
210 .I oldset
211 as NULL.
212 .SH SEE ALSO
213 .BR kill (2),
214 .BR pause (2),
215 .BR sigaction (2),
216 .BR signal (2),
217 .BR sigpending (2),
218 .BR sigsuspend (2),
219 .BR pthread_sigmask (3),
220 .BR sigqueue (3),
221 .BR sigsetops (3),
222 .BR signal (7)