1PTHREAD_ATTR_SETSIGMASK_NP(3L)inux Programmer's ManuPaTlHREAD_ATTR_SETSIGMASK_NP(3)
2
3
4

NAME

6       pthread_attr_setsigmask_np, pthread_attr_getsigmask_np - set/get signal
7       mask attribute in thread attributes object
8

SYNOPSIS

10       #define _GNU_SOURCE             /* See feature_test_macros(7) */
11       #include <pthread.h>
12
13       int pthread_attr_setsigmask_np(pthread_attr_t *attr,
14                                      const sigset_t *sigmask);
15       int pthread_attr_getsigmask_np(const pthread_attr_t *attr,
16                                      sigset_t *sigmask);
17
18       Compile and link with -pthread.
19

DESCRIPTION

21       The pthread_attr_setsigmask_np() function sets the signal  mask  attri‐
22       bute  of  the thread attributes object referred to by attr to the value
23       specified in *sigmask.  If sigmask is specified as NULL, then  any  ex‐
24       isting signal mask attribute in attr is unset.
25
26       The  pthread_attr_getsigmask_np()  function returns the signal mask at‐
27       tribute of the thread attributes object referred to by attr in the buf‐
28       fer  pointed  to by sigmask.  If the signal mask attribute is currently
29       unset,   then    this    function    returns    the    special    value
30       PTHREAD_ATTR_NO_SIGMASK_NP as its result.
31

RETURN VALUE

33       The  pthread_attr_setsigmask_np()  function  returns 0 on success, or a
34       nonzero error number on failure.
35
36       the  pthread_attr_getsigmask_np()  function   returns   either   0   or
37       PTHREAD_ATTR_NO_SIGMASK_NP.  When 0 is returned, the signal mask attri‐
38       bute is returned via sigmask.  A return value  of  PTHREAD_ATTR_NO_SIG‐
39       MASK_NP indicates that the signal mask attribute is not set in attr.
40
41       On error, these functions return a positive error number.
42

ERRORS

44       ENOMEM (pthread_attr_setsigmask_np()) Could not allocate memory.
45

VERSIONS

47       These functions are provided by glibc since version 2.32.
48

ATTRIBUTES

50       For  an  explanation  of  the  terms  used  in  this  section,  see at‐
51       tributes(7).
52
53       ┌────────────────────────────────────────────┬───────────────┬─────────┐
54Interface                                   Attribute     Value   
55       ├────────────────────────────────────────────┼───────────────┼─────────┤
56pthread_attr_setsigmask_np(),               │ Thread safety │ MT-Safe │
57pthread_attr_getsigmask_np()                │               │         │
58       └────────────────────────────────────────────┴───────────────┴─────────┘
59

CONFORMING TO

61       These  functions are nonstandard GNU extensions; hence the suffix "_np"
62       (nonportable) in the names.
63

NOTES

65       The signal mask attribute determines the signal mask that will  be  as‐
66       signed to a thread created using the thread attributes object attr.  If
67       this attribute is not set, then a thread created using attr will inher‐
68       it a copy of the creating thread's signal mask.
69
70       For  more  details on signal masks, see sigprocmask(2).  For a descrip‐
71       tion of a set of macros that can be used to manipulate and inspect sig‐
72       nal sets, see sigsetops(3).
73
74       In the absence of pthread_attr_setsigmask_np() it is possible to create
75       a thread with a desired signal mask as follows:
76
77       • The creating thread uses pthread_sigmask(3) to save its current  sig‐
78         nal mask and set its mask to block all signals.
79
80       • The new thread is then created using pthread_create(); the new thread
81         will inherit the creating thread's signal mask.
82
83       • The new thread sets its  signal  mask  to  the  desired  value  using
84         pthread_sigmask(3).
85
86       • The creating thread restores its signal mask to the original value.
87
88       Following  the  above steps, there is no possibility for the new thread
89       to receive a signal before it has adjusted its signal mask to  the  de‐
90       sired value.
91

SEE ALSO

93       sigprocmask(2),  pthread_attr_init(3), pthread_sigmask(3), pthreads(7),
94       signal(7)
95

COLOPHON

97       This page is part of release 5.13 of the Linux  man-pages  project.   A
98       description  of  the project, information about reporting bugs, and the
99       latest    version    of    this    page,    can     be     found     at
100       https://www.kernel.org/doc/man-pages/.
101
102
103
104Linux                             2021-03-22     PTHREAD_ATTR_SETSIGMASK_NP(3)
Impressum