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