Multithreaded Programming Guide


pthread_mutexattr_setrobust_np(3T) sets the robust attribute of a mutex attribute object.

#include <pthread.h>

int pthread_mutexattr_setrobust_np(pthread_mutexatt_t *attr, int *robustness);

Note -

pthread_mutexattr_setrobust_np() applies only if the symbol _POSIX_THREAD_PRIO_INHERIT is defined.

attr points to the mutex attribute object previously created by a call to pthread_mutexattr_init().

robustness defines the behavior when the owner of the mutex dies. The value of robustness, defined in pthread.h, is PTHREAD_MUTEX_ROBUST_NP or PTHREAD_MUTEX_STALLED_NP. The default value is PTHREAD_MUTEX_STALLED_NP.

Return Values

On successful completion, pthread_mutexattr_setrobust_np() returns 0. Any other returned value indicates that an error occurred.

If any of the following conditions occurs, pthread_mutexattr_setrobust_np() fails and returns the corresponding value.


The option _POSIX_THREAD_PRIO__INHERIT is not defined or the implementation does not support pthread_mutexattr_setrobust_np().


The value specified by robustness is not supported.

pthread_mutexattr_setrobust_np() might fail if:


The value specified by attr or robustness is invalid.