1SIGPROCMASK(2) Linux Programmer's Manual SIGPROCMASK(2)
2
3
4
6 sigprocmask, rt_sigprocmask - examine and change blocked signals
7
9 #include <signal.h>
10
11 /* Prototype for the glibc wrapper function */
12 int sigprocmask(int how, const sigset_t *restrict set,
13 sigset_t *restrict oldset);
14
15 #include <signal.h> /* Definition of SIG_* constants */
16 #include <sys/syscall.h> /* Definition of SYS_* constants */
17 #include <unistd.h>
18
19 /* Prototype for the underlying system call */
20 int syscall(SYS_rt_sigprocmask, int how, const kernel_sigset_t *set,
21 kernel_sigset_t *oldset, size_t sigsetsize);
22
23 /* Prototype for the legacy system call (deprecated) */
24 int syscall(SYS_sigprocmask, int how, const old_kernel_sigset_t *set,
25 old_kernel_sigset_t *oldset);
26
27 Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
28
29 sigprocmask():
30 _POSIX_C_SOURCE
31
33 sigprocmask() is used to fetch and/or change the signal mask of the
34 calling thread. The signal mask is the set of signals whose delivery
35 is currently blocked for the caller (see also signal(7) for more de‐
36 tails).
37
38 The behavior of the call is dependent on the value of how, as follows.
39
40 SIG_BLOCK
41 The set of blocked signals is the union of the current set and
42 the set argument.
43
44 SIG_UNBLOCK
45 The signals in set are removed from the current set of blocked
46 signals. It is permissible to attempt to unblock a signal which
47 is not blocked.
48
49 SIG_SETMASK
50 The set of blocked signals is set to the argument set.
51
52 If oldset is non-NULL, the previous value of the signal mask is stored
53 in oldset.
54
55 If set is NULL, then the signal mask is unchanged (i.e., how is ig‐
56 nored), but the current value of the signal mask is nevertheless re‐
57 turned in oldset (if it is not NULL).
58
59 A set of functions for modifying and inspecting variables of type
60 sigset_t ("signal sets") is described in sigsetops(3).
61
62 The use of sigprocmask() is unspecified in a multithreaded process; see
63 pthread_sigmask(3).
64
66 sigprocmask() returns 0 on success. On failure, -1 is returned and er‐
67 rno is set to indicate the error.
68
70 EFAULT The set or oldset argument points outside the process's allo‐
71 cated address space.
72
73 EINVAL Either the value specified in how was invalid or the kernel does
74 not support the size passed in sigsetsize.
75
77 POSIX.1-2001, POSIX.1-2008.
78
80 It is not possible to block SIGKILL or SIGSTOP. Attempts to do so are
81 silently ignored.
82
83 Each of the threads in a process has its own signal mask.
84
85 A child created via fork(2) inherits a copy of its parent's signal
86 mask; the signal mask is preserved across execve(2).
87
88 If SIGBUS, SIGFPE, SIGILL, or SIGSEGV are generated while they are
89 blocked, the result is undefined, unless the signal was generated by
90 kill(2), sigqueue(3), or raise(3).
91
92 See sigsetops(3) for details on manipulating signal sets.
93
94 Note that it is permissible (although not very useful) to specify both
95 set and oldset as NULL.
96
97 C library/kernel differences
98 The kernel's definition of sigset_t differs in size from that used by
99 the C library. In this manual page, the former is referred to as ker‐
100 nel_sigset_t (it is nevertheless named sigset_t in the kernel sources).
101
102 The glibc wrapper function for sigprocmask() silently ignores attempts
103 to block the two real-time signals that are used internally by the NPTL
104 threading implementation. See nptl(7) for details.
105
106 The original Linux system call was named sigprocmask(). However, with
107 the addition of real-time signals in Linux 2.2, the fixed-size, 32-bit
108 sigset_t (referred to as old_kernel_sigset_t in this manual page) type
109 supported by that system call was no longer fit for purpose. Conse‐
110 quently, a new system call, rt_sigprocmask(), was added to support an
111 enlarged sigset_t type (referred to as kernel_sigset_t in this manual
112 page). The new system call takes a fourth argument, size_t sigsetsize,
113 which specifies the size in bytes of the signal sets in set and oldset.
114 This argument is currently required to have a fixed architecture spe‐
115 cific value (equal to sizeof(kernel_sigset_t)).
116
117 The glibc sigprocmask() wrapper function hides these details from us,
118 transparently calling rt_sigprocmask() when the kernel provides it.
119
121 kill(2), pause(2), sigaction(2), signal(2), sigpending(2), sigsus‐
122 pend(2), pthread_sigmask(3), sigqueue(3), sigsetops(3), signal(7)
123
125 This page is part of release 5.13 of the Linux man-pages project. A
126 description of the project, information about reporting bugs, and the
127 latest version of this page, can be found at
128 https://www.kernel.org/doc/man-pages/.
129
130
131
132Linux 2021-03-22 SIGPROCMASK(2)