1 .\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
2 .\" <mtk.manpages@gmail.com>
4 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
6 .TH PTHREAD_ATTR_SETSIGMASK_NP 3 2021-03-22 "Linux" "Linux Programmer's Manual"
8 pthread_attr_setsigmask_np, pthread_attr_getsigmask_np \- set/get
9 signal mask attribute in thread attributes object
12 .RI ( libpthread ", " \-lpthread )
15 .BR "#define _GNU_SOURCE" " /* See feature_test_macros(7) */"
16 .B #include <pthread.h>
18 .BI "int pthread_attr_setsigmask_np(pthread_attr_t *" attr ,
19 .BI " const sigset_t *" sigmask );
20 .BI "int pthread_attr_getsigmask_np(const pthread_attr_t *" attr ,
21 .BI " sigset_t *" sigmask );
25 .BR pthread_attr_setsigmask_np ()
26 function sets the signal mask attribute of the
27 thread attributes object referred to by
29 to the value specified in
33 is specified as NULL, then any existing signal mask attribute in
38 .BR pthread_attr_getsigmask_np ()
39 function returns the signal mask attribute of the thread attributes object
42 in the buffer pointed to by
44 If the signal mask attribute is currently unset,
45 then this function returns the special value
46 .B PTHREAD_ATTR_NO_SIGMASK_NP
50 .BR pthread_attr_setsigmask_np ()
51 function returns 0 on success, or a nonzero error number on failure.
54 .BR pthread_attr_getsigmask_np ()
55 function returns either 0 or
56 .BR PTHREAD_ATTR_NO_SIGMASK_NP .
57 When 0 is returned, the signal mask attribute is returned via
60 .B PTHREAD_ATTR_NO_SIGMASK_NP
61 indicates that the signal mask attribute is not set in
64 On error, these functions return a positive error number.
68 .RB ( pthread_attr_setsigmask_np ())
69 Could not allocate memory.
71 These functions are provided by glibc since version 2.32.
73 For an explanation of the terms used in this section, see
81 Interface Attribute Value
83 .BR pthread_attr_setsigmask_np (),
84 .BR pthread_attr_getsigmask_np ()
85 T} Thread safety MT-Safe
91 These functions are nonstandard GNU extensions;
92 hence the suffix "_np" (nonportable) in the names.
94 The signal mask attribute determines the signal mask that will be assigned to
95 a thread created using the thread attributes object
97 If this attribute is not set, then a thread created using
99 will inherit a copy of the creating thread's signal mask.
101 For more details on signal masks, see
103 For a description of a set of macros
104 that can be used to manipulate and inspect signal sets, see
108 .BR pthread_attr_setsigmask_np ()
109 it is possible to create a thread with a desired signal mask as follows:
111 The creating thread uses
112 .BR pthread_sigmask (3)
113 to save its current signal mask and set its mask to block all signals.
115 The new thread is then created using
116 .BR pthread_create ();
117 the new thread will inherit the creating thread's signal mask.
119 The new thread sets its signal mask to the desired value using
120 .BR pthread_sigmask (3).
122 The creating thread restores its signal mask to the original value.
124 Following the above steps,
125 there is no possibility for the new thread to receive a signal
126 before it has adjusted its signal mask to the desired value.
129 .BR pthread_attr_init (3),
130 .BR pthread_sigmask (3),