]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man2/sigprocmask.2
Removed trailing white space at end of lines
[thirdparty/man-pages.git] / man2 / sigprocmask.2
1 .\" Copyright (c) 2005 Michael Kerrisk
2 .\" based on earlier work by faith@cs.unc.edu and
3 .\" Mike Battersby <mib@deakin.edu.au>
4 .\"
5 .\" %%%LICENSE_START(VERBATIM)
6 .\" Permission is granted to make and distribute verbatim copies of this
7 .\" manual provided the copyright notice and this permission notice are
8 .\" preserved on all copies.
9 .\"
10 .\" Permission is granted to copy and distribute modified versions of this
11 .\" manual under the conditions for verbatim copying, provided that the
12 .\" entire resulting derived work is distributed under the terms of a
13 .\" permission notice identical to this one.
14 .\"
15 .\" Since the Linux kernel and libraries are constantly changing, this
16 .\" manual page may be incorrect or out-of-date. The author(s) assume no
17 .\" responsibility for errors or omissions, or for damages resulting from
18 .\" the use of the information contained herein. The author(s) may not
19 .\" have taken the same level of care in the production of this manual,
20 .\" which is licensed free of charge, as they might when working
21 .\" professionally.
22 .\"
23 .\" Formatted or processed versions of this manual, if unaccompanied by
24 .\" the source, must acknowledge the copyright and authors of this work.
25 .\" %%%LICENSE_END
26 .\"
27 .\" 2005-09-15, mtk, Created new page by splitting off from sigaction.2
28 .\"
29 .TH SIGPROCMASK 2 2017-09-15 "Linux" "Linux Programmer's Manual"
30 .SH NAME
31 sigprocmask, rt_sigprocmask \- examine and change blocked signals
32 .SH SYNOPSIS
33 .B #include <signal.h>
34 .PP
35 .nf
36 /* Prototype for the glibc wrapper function */
37 .BI "int sigprocmask(int " how ", const sigset_t *" set ", sigset_t *" oldset );
38 .PP
39 /* Prototype for the underlying system call */
40 .BI "int rt_sigprocmask(int " how ", const kernel_sigset_t *" set ,
41 .BI " kernel_sigset_t *" oldset ", size_t " sigsetsize );
42 .PP
43 /* Prototype for the legacy system call (deprecated) */
44 .BI "int sigprocmask(int " how ", const old_kernel_sigset_t *" set ,
45 .BI " old_kernel_sigset_t *" oldset ); "
46 .fi
47 .PP
48 .in -4n
49 Feature Test Macro Requirements for glibc (see
50 .BR feature_test_macros (7)):
51 .in
52 .PP
53 .ad l
54 .BR sigprocmask ():
55 _POSIX_C_SOURCE
56 .ad b
57 .SH DESCRIPTION
58 .BR sigprocmask ()
59 is used to fetch and/or change the signal mask of the calling thread.
60 The signal mask is the set of signals whose delivery is currently
61 blocked for the caller
62 (see also
63 .BR signal (7)
64 for more details).
65 .PP
66 The behavior of the call is dependent on the value of
67 .IR how ,
68 as follows.
69 .TP
70 .B SIG_BLOCK
71 The set of blocked signals is the union of the current set and the
72 .I set
73 argument.
74 .TP
75 .B SIG_UNBLOCK
76 The signals in
77 .I set
78 are removed from the current set of blocked signals.
79 It is permissible to attempt to unblock a signal which is not blocked.
80 .TP
81 .B SIG_SETMASK
82 The set of blocked signals is set to the argument
83 .IR set .
84 .PP
85 If
86 .I oldset
87 is non-NULL, the previous value of the signal mask is stored in
88 .IR oldset .
89 .PP
90 If
91 .I set
92 is NULL, then the signal mask is unchanged (i.e.,
93 .I how
94 is ignored),
95 but the current value of the signal mask is nevertheless returned in
96 .I oldset
97 (if it is not NULL).
98 .PP
99 A set of functions for modifying and inspecting variables of type
100 .I sigset_t
101 ("signal sets") is described in
102 .BR sigsetops (3).
103 .PP
104 The use of
105 .BR sigprocmask ()
106 is unspecified in a multithreaded process; see
107 .BR pthread_sigmask (3).
108 .SH RETURN VALUE
109 .BR sigprocmask ()
110 returns 0 on success and \-1 on error.
111 In the event of an error,
112 .I errno
113 is set to indicate the cause.
114 .SH ERRORS
115 .TP
116 .B EFAULT
117 The
118 .I set
119 or
120 .I oldset
121 argument points outside the process's allocated address space.
122 .TP
123 .B EINVAL
124 Either the value specified in
125 .I how
126 was invalid or the kernel does not support the size passed in
127 .I sigsetsize.
128 .SH CONFORMING TO
129 POSIX.1-2001, POSIX.1-2008.
130 .SH NOTES
131 It is not possible to block
132 .BR SIGKILL " or " SIGSTOP .
133 Attempts to do so are silently ignored.
134 .PP
135 Each of the threads in a process has its own signal mask.
136 .PP
137 A child created via
138 .BR fork (2)
139 inherits a copy of its parent's signal mask;
140 the signal mask is preserved across
141 .BR execve (2).
142 .PP
143 If
144 .BR SIGBUS ,
145 .BR SIGFPE ,
146 .BR SIGILL ,
147 or
148 .B SIGSEGV
149 are generated
150 while they are blocked, the result is undefined,
151 unless the signal was generated by
152 .BR kill (2),
153 .BR sigqueue (3),
154 or
155 .BR raise (3).
156 .PP
157 See
158 .BR sigsetops (3)
159 for details on manipulating signal sets.
160 .PP
161 Note that it is permissible (although not very useful) to specify both
162 .I set
163 and
164 .I oldset
165 as NULL.
166 .\"
167 .SS C library/kernel differences
168 .PP
169 The kernel's definition of
170 .IR sigset_t
171 differs in size from that used
172 by the C library.
173 In this manual page, the former is referred to as
174 .I kernel_sigset_t
175 (it is nevertheless named
176 .I sigset_t
177 in the kernel sources).
178 .PP
179 The glibc wrapper function for
180 .BR sigprocmask ()
181 silently ignores attempts to block the two real-time signals that
182 are used internally by the NPTL threading implementation.
183 See
184 .BR nptl (7)
185 for details.
186 .PP
187 The original Linux system call was named
188 .BR sigprocmask ().
189 However, with the addition of real-time signals in Linux 2.2,
190 the fixed-size, 32-bit
191 .IR sigset_t
192 (referred to as
193 .IR old_kernel_sigset_t
194 in this manual page)
195 type supported by that system call was no longer fit for purpose.
196 Consequently, a new system call,
197 .BR rt_sigprocmask (),
198 was added to support an enlarged
199 .IR sigset_t
200 type
201 (referred to as
202 .IR kernel_sigset_t
203 in this manual page).
204 The new system call takes a fourth argument,
205 .IR "size_t sigsetsize" ,
206 which specifies the size in bytes of the signal sets in
207 .IR set
208 and
209 .IR oldset .
210 This argument is currently required to have a fixed architecture specific value
211 (equal to
212 .IR sizeof(kernel_sigset_t) ).
213 .\" sizeof(kernel_sigset_t) == _NSIG / 8,
214 .\" which equals to 8 on most architectures, but e.g. on MIPS it's 16.
215 .PP
216 The glibc
217 .BR sigprocmask ()
218 wrapper function hides these details from us, transparently calling
219 .BR rt_sigprocmask ()
220 when the kernel provides it.
221 .\"
222 .SH SEE ALSO
223 .BR kill (2),
224 .BR pause (2),
225 .BR sigaction (2),
226 .BR signal (2),
227 .BR sigpending (2),
228 .BR sigsuspend (2),
229 .BR pthread_sigmask (3),
230 .BR sigqueue (3),
231 .BR sigsetops (3),
232 .BR signal (7)