pthread_attr_setsigmask_np, pthread_attr_getsigmask_np — set/get signal mask attribute in thread attributes object
#define _GNU_SOURCE /* See feature_test_macros(7) */ #include <pthread.h>
int
pthread_attr_setsigmask_np( |
pthread_attr_t *attr, |
const sigset_t *sigmask) ; |
int
pthread_attr_getsigmask_np( |
const pthread_attr_t *attr, |
sigset_t *sigmask) ; |
Note | |
---|---|
Compile and link with |
The pthread_attr_setsigmask_np
() function sets
the signal mask attribute of the thread attributes object
referred to by attr
to the value specified in *sigmask
. If sigmask
is specified as NULL,
then any existing signal mask attribute in attr
is unset.
The pthread_attr_getsigmask_np
() function
returns the signal mask attribute of the thread attributes
object referred to by attr
in the buffer pointed to
by sigmask
. If the
signal mask attribute is currently unset, then this function
returns the special value PTHREAD_ATTR_NO_SIGMASK_NP
as its
result.
The pthread_attr_setsigmask_np
() function
returns 0 on success, or a nonzero error number on
failure.
the pthread_attr_getsigmask_np
() function
returns either 0 or PTHREAD_ATTR_NO_SIGMASK_NP
. When 0 is
returned, the signal mask attribute is returned via
sigmask
. A return
value of PTHREAD_ATTR_NO_SIGMASK_NP
indicates that
the signal mask attribute is not set in attr
.
On error, these functions return a positive error number.
For an explanation of the terms used in this section, see attributes(7).
Interface | Attribute | Value |
pthread_attr_setsigmask_np (),
pthread_attr_getsigmask_np () |
Thread safety | MT-Safe |
These functions are nonstandard GNU extensions; hence the suffix "_np" (nonportable) in the names.
The signal mask attribute determines the signal mask that
will be assigned to a thread created using the thread
attributes object attr
. If this attribute is not
set, then a thread created using attr
will inherit a copy of the
creating thread's signal mask.
For more details on signal masks, see sigprocmask(2). For a description of a set of macros that can be used to manipulate and inspect signal sets, see sigsetops(3).
In the absence of pthread_attr_setsigmask_np
() it is possible
to create a thread with a desired signal mask as follows:
The creating thread uses pthread_sigmask(3) to save its current signal mask and set its mask to block all signals.
The new thread is then created using pthread_create
(); the new thread will
inherit the creating thread's signal mask.
The new thread sets its signal mask to the desired value using pthread_sigmask(3).
The creating thread restores its signal mask to the original value.
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.
This page is part of release 5.11 of the Linux man-pages
project. A
description of the project, information about reporting bugs,
and the latest version of this page, can be found at
https://www.kernel.org/doc/man−pages/.
Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk <mtk.manpagesgmail.com> %%%LICENSE_START(VERBATIM) Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies. Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one. Since the Linux kernel and libraries are constantly changing, this manual page may be incorrect or out-of-date. The author(s) assume no responsibility for errors or omissions, or for damages resulting from the use of the information contained herein. The author(s) may not have taken the same level of care in the production of this manual, which is licensed free of charge, as they might when working professionally. Formatted or processed versions of this manual, if unaccompanied by the source, must acknowledge the copyright and authors of this work. %%%LICENSE_END |