---
name: "pthread_attr_setsigmask_np"
section: "3"
platform: "linux"
package: "man-pages"
version: "6.19-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/pthread_attr_setsigmask_np"
---

# pthread\_attr\_setsigmask\_np(3)

set/get signal mask attribute in thread attributes object

## NAME

pthread\_attr\_setsigmask\_np, pthread\_attr\_getsigmask\_np - set/get signal mask attribute in thread attributes object

## LIBRARY

POSIX threads library (*libpthread*, *-lpthread*)

## SYNOPSIS

```
#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***);**

## DESCRIPTION

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.

## RETURN VALUE

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.

## ERRORS

- **ENOMEM**

  (**pthread\_attr\_setsigmask\_np**()) Could not allocate memory.

## ATTRIBUTES

For an explanation of the terms used in this section, see [**attributes**(7)](/attributes/7.md).

| | | |
| --- | --- | --- |
| **Interface** | **Attribute** | **Value** |
| **pthread\_attr\_setsigmask\_np**(), **pthread\_attr\_getsigmask\_np**() | Thread safety | MT-Safe |

## STANDARDS

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

## HISTORY

glibc 2.32.

## NOTES

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)](/sigprocmask/2.md). For a description of a set of macros that can be used to manipulate and inspect signal sets, see [**sigsetops**(3)](/sigsetops/3.md).

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)](/pthread_sigmask/3.md) 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)](/pthread_sigmask/3.md).

- •

  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.

## SEE ALSO

[**sigprocmask**(2)](/sigprocmask/2.md), [**pthread\_attr\_init**(3)](/pthread_attr_init/3.md), [**pthread\_sigmask**(3)](/pthread_sigmask/3.md), [**pthreads**(7)](/pthreads/7.md), [**signal**(7)](/signal/7.md)
