Debian Codegraph @

upstream/debian-trixie/man3/pthread_attr_setsigmask_np.3

raw
1 '\" t
2 .\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
3 .\" <[email protected]>
4 .\"
5 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
6 .\"
7 .TH pthread_attr_setsigmask_np 3 2024-05-02 "Linux man-pages 6.9.1"
8 .SH NAME
9 pthread_attr_setsigmask_np, pthread_attr_getsigmask_np \- set/get
10 signal mask attribute in thread attributes object
11 .SH LIBRARY
12 POSIX threads library
13 .RI ( libpthread ", " \-lpthread )
14 .SH SYNOPSIS
15 .nf
16 .BR "#define _GNU_SOURCE" " /* See feature_test_macros(7) */"
17 .B #include <pthread.h>
18 .P
19 .BI "int pthread_attr_setsigmask_np(pthread_attr_t *" attr ,
20 .BI " const sigset_t *" sigmask );
21 .BI "int pthread_attr_getsigmask_np(const pthread_attr_t *" attr ,
22 .BI " sigset_t *" sigmask );
23 .fi
24 .SH DESCRIPTION
25 The
26 .BR pthread_attr_setsigmask_np ()
27 function sets the signal mask attribute of the
28 thread attributes object referred to by
29 .I attr
30 to the value specified in
31 .IR *sigmask .
32 If
33 .I sigmask
34 is specified as NULL, then any existing signal mask attribute in
35 .I attr
36 is unset.
37 .P
38 The
39 .BR pthread_attr_getsigmask_np ()
40 function returns the signal mask attribute of the thread attributes object
41 referred to by
42 .I attr
43 in the buffer pointed to by
44 .IR sigmask .
45 If the signal mask attribute is currently unset,
46 then this function returns the special value
47 .B PTHREAD_ATTR_NO_SIGMASK_NP
48 as its result.
49 .SH RETURN VALUE
50 The
51 .BR pthread_attr_setsigmask_np ()
52 function returns 0 on success, or a nonzero error number on failure.
53 .P
54 the
55 .BR pthread_attr_getsigmask_np ()
56 function returns either 0 or
57 .BR PTHREAD_ATTR_NO_SIGMASK_NP .
58 When 0 is returned, the signal mask attribute is returned via
59 .IR sigmask .
60 A return value of
61 .B PTHREAD_ATTR_NO_SIGMASK_NP
62 indicates that the signal mask attribute is not set in
63 .IR attr .
64 .P
65 On error, these functions return a positive error number.
66 .SH ERRORS
67 .TP
68 .B ENOMEM
69 .RB ( pthread_attr_setsigmask_np ())
70 Could not allocate memory.
71 .SH ATTRIBUTES
72 For an explanation of the terms used in this section, see
73 .BR attributes (7).
74 .TS
75 allbox;
76 lbx lb lb
77 l l l.
78 Interface Attribute Value
79 T{
80 .na
81 .nh
82 .BR pthread_attr_setsigmask_np (),
83 .BR pthread_attr_getsigmask_np ()
84 T} Thread safety MT-Safe
85 .TE
86 .SH STANDARDS
87 GNU;
88 hence the suffix "_np" (nonportable) in the names.
89 .SH HISTORY
90 glibc 2.32.
91 .SH NOTES
92 The signal mask attribute determines the signal mask that will be assigned to
93 a thread created using the thread attributes object
94 .IR attr .
95 If this attribute is not set, then a thread created using
96 .I attr
97 will inherit a copy of the creating thread's signal mask.
98 .P
99 For more details on signal masks, see
100 .BR sigprocmask (2).
101 For a description of a set of macros
102 that can be used to manipulate and inspect signal sets, see
103 .BR sigsetops (3).
104 .P
105 In the absence of
106 .BR pthread_attr_setsigmask_np ()
107 it is possible to create a thread with a desired signal mask as follows:
108 .IP \[bu] 3
109 The creating thread uses
110 .BR pthread_sigmask (3)
111 to save its current signal mask and set its mask to block all signals.
112 .IP \[bu]
113 The new thread is then created using
114 .BR pthread_create ();
115 the new thread will inherit the creating thread's signal mask.
116 .IP \[bu]
117 The new thread sets its signal mask to the desired value using
118 .BR pthread_sigmask (3).
119 .IP \[bu]
120 The creating thread restores its signal mask to the original value.
121 .P
122 Following the above steps,
123 there is no possibility for the new thread to receive a signal
124 before it has adjusted its signal mask to the desired value.
125 .SH SEE ALSO
126 .BR sigprocmask (2),
127 .BR pthread_attr_init (3),
128 .BR pthread_sigmask (3),
129 .BR pthreads (7),
130 .BR signal (7)