pthread_mutexattr_init(3)

pthread_mutexattr_init3

Initialize and destroy a mutex attributes object

Usage

#include <pthread.h>

int pthread_mutexattr_init(pthread_mutexattr_t *attr); int pthread_mutexattr_destroy(pthread_mutexattr_t *attr);

Library

POSIX threads library (libpthread, -lpthread)

Overview

The pthread_mutexattr_init() function initializes the mutex attributes object pointed to by attr with default values for all attributes defined by the implementation.

The results of initializing an already initialized mutex attributes object are undefined.

The pthread_mutexattr_destroy() function destroys a mutex attribute object (making it uninitialized). Once a mutex attributes object has been destroyed, it can be reinitialized with pthread_mutexattr_init().

The results of destroying an uninitialized mutex attributes object are undefined.

Return value

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

Notes

Subsequent changes to a mutex attributes object do not affect mutex that have already been initialized using that object.

Releases

12 releases since Debian 3.1 (Sarge); the text changed 4 times.

  1. 3.1
  2. 4.0–5.0
  3. 6.0–12
  4. 13
  5. Arch

Standards

POSIX.1-2008.

History

POSIX.1-2001.

From man-pages 6.19-1 in Arch Linux 2026-11-01. Parsed by carta from the page's man source.