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

# pthread\_mutexattr\_getpshared(3)

get/set process-shared mutex attribute

## NAME

pthread\_mutexattr\_getpshared, pthread\_mutexattr\_setpshared - get/set process-shared mutex attribute

## LIBRARY

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

## SYNOPSIS

```
#include <pthread.h>
```

**int pthread\_mutexattr\_getpshared(**                       **const pthread\_mutexattr\_t \*restrict** *attr***,**                       **int \*restrict** *pshared***);** **int pthread\_mutexattr\_setpshared(pthread\_mutexattr\_t \****attr***,**                       **int** *pshared***);**

## DESCRIPTION

These functions get and set the process-shared attribute in a mutex attributes object. This attribute must be appropriately set to ensure correct, efficient operation of a mutex created using this attributes object.

The process-shared attribute can have one of the following values:

- **PTHREAD\_PROCESS\_PRIVATE**

  Mutexes created with this attributes object are to be shared only among threads in the same process that initialized the mutex. This is the default value for the process-shared mutex attribute.

- **PTHREAD\_PROCESS\_SHARED**

  Mutexes created with this attributes object can be shared between any threads that have access to the memory containing the object, including threads in different processes.

**pthread\_mutexattr\_getpshared**() places the value of the process-shared attribute of the mutex attributes object referred to by *attr* in the location pointed to by *pshared*.

**pthread\_mutexattr\_setpshared**() sets the value of the process-shared attribute of the mutex attributes object referred to by *attr* to the value specified in **pshared**.

If *attr* does not refer to an initialized mutex attributes object, the behavior is undefined.

## RETURN VALUE

On success, these functions return 0. On error, they return a positive error number.

## ERRORS

**pthread\_mutexattr\_setpshared**() can fail with the following errors:

- **EINVAL**

  The value specified in *pshared* is invalid.

- **ENOTSUP**

  *pshared* is **PTHREAD\_PROCESS\_SHARED** but the implementation does not support process-shared mutexes.

## STANDARDS

POSIX.1-2008.

## HISTORY

POSIX.1-2001.

## SEE ALSO

[**pthread\_mutexattr\_init**(3)](/pthread_mutexattr_init/3.md), [**pthreads**(7)](/pthreads/7.md)
