]>
Commit | Line | Data |
---|---|---|
7ff599e2 | 1 | .\" Copyright (c) 2005 Michael Kerrisk |
c13182ef | 2 | .\" based on earlier work by faith@cs.unc.edu and |
7ff599e2 MK |
3 | .\" Mike Battersby <mib@deakin.edu.au> |
4 | .\" | |
5fbde956 | 5 | .\" SPDX-License-Identifier: Linux-man-pages-copyleft |
7ff599e2 MK |
6 | .\" |
7 | .\" 2005-09-15, mtk, Created new page by splitting off from sigaction.2 | |
8 | .\" | |
45186a5d | 9 | .TH SIGPROCMASK 2 2021-03-22 "Linux man-pages (unreleased)" |
7ff599e2 | 10 | .SH NAME |
166b65db | 11 | sigprocmask, rt_sigprocmask \- examine and change blocked signals |
bc57a2c9 AC |
12 | .SH LIBRARY |
13 | Standard C library | |
8fc3b2cf | 14 | .RI ( libc ", " \-lc ) |
7ff599e2 MK |
15 | .SH SYNOPSIS |
16 | .B #include <signal.h> | |
68e4db0a | 17 | .PP |
86d5ed87 KF |
18 | .nf |
19 | /* Prototype for the glibc wrapper function */ | |
1c227750 AC |
20 | .BI "int sigprocmask(int " how ", const sigset_t *restrict " set , |
21 | .BI " sigset_t *restrict " oldset ); | |
dbfe9c70 | 22 | .PP |
1b4d275a AC |
23 | .BR "#include <signal.h>" " /* Definition of " SIG_* " constants */" |
24 | .BR "#include <sys/syscall.h>" " /* Definition of " SYS_* " constants */" | |
25 | .B #include <unistd.h> | |
26 | .PP | |
86d5ed87 | 27 | /* Prototype for the underlying system call */ |
1b4d275a | 28 | .BI "int syscall(SYS_rt_sigprocmask, int " how ", const kernel_sigset_t *" set , |
f2667a72 | 29 | .BI " kernel_sigset_t *" oldset ", size_t " sigsetsize ); |
dbfe9c70 | 30 | .PP |
86d5ed87 | 31 | /* Prototype for the legacy system call (deprecated) */ |
1b4d275a | 32 | .BI "int syscall(SYS_sigprocmask, int " how ", const old_kernel_sigset_t *" set , |
9bfc9cb1 | 33 | .BI " old_kernel_sigset_t *" oldset ); |
86d5ed87 | 34 | .fi |
68e4db0a | 35 | .PP |
d39ad78f | 36 | .RS -4 |
0f200f07 MK |
37 | Feature Test Macro Requirements for glibc (see |
38 | .BR feature_test_macros (7)): | |
d39ad78f | 39 | .RE |
68e4db0a | 40 | .PP |
0f200f07 | 41 | .BR sigprocmask (): |
9d2adbae MK |
42 | .nf |
43 | _POSIX_C_SOURCE | |
44 | .fi | |
7ff599e2 MK |
45 | .SH DESCRIPTION |
46 | .BR sigprocmask () | |
92ae3965 MK |
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 | |
4c5bcd47 MK |
50 | (see also |
51 | .BR signal (7) | |
52 | for more details). | |
efeece04 | 53 | .PP |
d9bfdb9c | 54 | The behavior of the call is dependent on the value of |
7ff599e2 MK |
55 | .IR how , |
56 | as follows. | |
7ff599e2 MK |
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 | |
c13182ef | 66 | are removed from the current set of blocked signals. |
e935e108 | 67 | It is permissible to attempt to unblock a signal which is not blocked. |
7ff599e2 MK |
68 | .TP |
69 | .B SIG_SETMASK | |
70 | The set of blocked signals is set to the argument | |
71 | .IR set . | |
7ff599e2 MK |
72 | .PP |
73 | If | |
74 | .I oldset | |
f38d8f71 | 75 | is non-NULL, the previous value of the signal mask is stored in |
7ff599e2 | 76 | .IR oldset . |
efeece04 | 77 | .PP |
7ff599e2 MK |
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 | |
0daa9e92 | 84 | .I oldset |
53e67125 | 85 | (if it is not NULL). |
efeece04 | 86 | .PP |
35acdc5d MK |
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). | |
efeece04 | 91 | .PP |
7ff599e2 MK |
92 | The use of |
93 | .BR sigprocmask () | |
94 | is unspecified in a multithreaded process; see | |
95 | .BR pthread_sigmask (3). | |
47297adb | 96 | .SH RETURN VALUE |
7ff599e2 | 97 | .BR sigprocmask () |
cb6a894e MK |
98 | returns 0 on success. |
99 | On failure, \-1 is returned and | |
2cbd0ac5 | 100 | .I errno |
cb6a894e | 101 | is set to indicate the error. |
7ff599e2 | 102 | .SH ERRORS |
ef301293 MF |
103 | .TP |
104 | .B EFAULT | |
57713dca | 105 | The |
ef301293 MF |
106 | .I set |
107 | or | |
108 | .I oldset | |
109 | argument points outside the process's allocated address space. | |
110 | .TP | |
7ff599e2 | 111 | .B EINVAL |
86d5ed87 | 112 | Either the value specified in |
7ff599e2 | 113 | .I how |
86d5ed87 KF |
114 | was invalid or the kernel does not support the size passed in |
115 | .I sigsetsize. | |
3113c7f3 | 116 | .SH STANDARDS |
2b724927 | 117 | POSIX.1-2001, POSIX.1-2008. |
7ff599e2 | 118 | .SH NOTES |
c13182ef | 119 | It is not possible to block |
7ff599e2 MK |
120 | .BR SIGKILL " or " SIGSTOP . |
121 | Attempts to do so are silently ignored. | |
efeece04 | 122 | .PP |
92ae3965 | 123 | Each of the threads in a process has its own signal mask. |
efeece04 | 124 | .PP |
eebf482d MK |
125 | A child created via |
126 | .BR fork (2) | |
127 | inherits a copy of its parent's signal mask; | |
128 | the signal mask is preserved across | |
129 | .BR execve (2). | |
efeece04 | 130 | .PP |
7ff599e2 MK |
131 | If |
132 | .BR SIGBUS , | |
c13182ef | 133 | .BR SIGFPE , |
7ff599e2 MK |
134 | .BR SIGILL , |
135 | or | |
0daa9e92 | 136 | .B SIGSEGV |
7ff599e2 MK |
137 | are generated |
138 | while they are blocked, the result is undefined, | |
736bedf6 | 139 | unless the signal was generated by |
7ff599e2 | 140 | .BR kill (2), |
485ab701 | 141 | .BR sigqueue (3), |
7ff599e2 MK |
142 | or |
143 | .BR raise (3). | |
144 | .PP | |
145 | See | |
146 | .BR sigsetops (3) | |
147 | for details on manipulating signal sets. | |
efeece04 | 148 | .PP |
b9ad845d MK |
149 | Note that it is permissible (although not very useful) to specify both |
150 | .I set | |
151 | and | |
152 | .I oldset | |
153 | as NULL. | |
166b65db | 154 | .\" |
0722a578 | 155 | .SS C library/kernel differences |
86d5ed87 | 156 | The kernel's definition of |
1ae6b2c7 | 157 | .I sigset_t |
86d5ed87 | 158 | differs in size from that used |
6c79a020 MK |
159 | by the C library. |
160 | In this manual page, the former is referred to as | |
86d5ed87 | 161 | .I kernel_sigset_t |
6c79a020 | 162 | (it is nevertheless named |
86d5ed87 KF |
163 | .I sigset_t |
164 | in the kernel sources). | |
efeece04 | 165 | .PP |
3699b154 MK |
166 | The glibc wrapper function for |
167 | .BR sigprocmask () | |
168 | silently ignores attempts to block the two real-time signals that | |
169 | are used internally by the NPTL threading implementation. | |
170 | See | |
171 | .BR nptl (7) | |
172 | for details. | |
efeece04 | 173 | .PP |
166b65db MK |
174 | The original Linux system call was named |
175 | .BR sigprocmask (). | |
176 | However, with the addition of real-time signals in Linux 2.2, | |
177 | the fixed-size, 32-bit | |
1ae6b2c7 | 178 | .I sigset_t |
86d5ed87 | 179 | (referred to as |
1ae6b2c7 | 180 | .I old_kernel_sigset_t |
6c79a020 | 181 | in this manual page) |
166b65db MK |
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 | |
1ae6b2c7 | 186 | .I sigset_t |
86d5ed87 KF |
187 | type |
188 | (referred to as | |
1ae6b2c7 | 189 | .I kernel_sigset_t |
6c79a020 | 190 | in this manual page). |
166b65db MK |
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 | |
1ae6b2c7 | 194 | .I set |
166b65db MK |
195 | and |
196 | .IR oldset . | |
ad8c02ab DL |
197 | This argument is currently required to have a fixed architecture specific value |
198 | (equal to | |
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. | |
efeece04 | 202 | .PP |
166b65db MK |
203 | The glibc |
204 | .BR sigprocmask () | |
205 | wrapper function hides these details from us, transparently calling | |
206 | .BR rt_sigprocmask () | |
207 | when the kernel provides it. | |
208 | .\" | |
47297adb | 209 | .SH SEE ALSO |
7ff599e2 MK |
210 | .BR kill (2), |
211 | .BR pause (2), | |
212 | .BR sigaction (2), | |
213 | .BR signal (2), | |
214 | .BR sigpending (2), | |
7ff599e2 MK |
215 | .BR sigsuspend (2), |
216 | .BR pthread_sigmask (3), | |
485ab701 | 217 | .BR sigqueue (3), |
7ff599e2 MK |
218 | .BR sigsetops (3), |
219 | .BR signal (7) |