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