1pthread_attr_setsigmask_np(3L)ibrary Functions Manuaplthread_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

LIBRARY

10       POSIX threads library (libpthread, -lpthread)
11

SYNOPSIS

13       #define _GNU_SOURCE             /* See feature_test_macros(7) */
14       #include <pthread.h>
15
16       int pthread_attr_setsigmask_np(pthread_attr_t *attr,
17                                      const sigset_t *sigmask);
18       int pthread_attr_getsigmask_np(const pthread_attr_t *attr,
19                                      sigset_t *sigmask);
20

DESCRIPTION

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

RETURN VALUE

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

ERRORS

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

ATTRIBUTES

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

STANDARDS

59       GNU; hence the suffix "_np" (nonportable) in the names.
60

HISTORY

62       glibc 2.32.
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
81          thread 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
96
97
98Linux man-pages 6.04              2023-03-30     pthread_attr_setsigmask_np(3)
Impressum