#include <pthread.h> int pthread_mutexattr_setrobust_np(pthread_mutexatt_t *attr, int *robustness);
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.
When the owner of the mutex dies, all subsequent calls to pthread_mutex_lock() are blocked from progress in an unspecified manner.
When the owner of the mutex dies, the mutex is unlocked. The next owner of this mutex acquires it with an error return of EOWNWERDEAD.
Your application must check the return code from pthread_mutex_lock() for a mutex of this type.
The new owner of this mutex should make the state protected by the mutex consistent; this state might have been left inconsistent when the previous owner died.
If the new owner is able to make the state consistent, call pthread_mutex_consistent_np() for the mutex, and unlock the mutex.
If the new owner is not able to make the state consistent, do not call pthread_mutex_consistent_np() for the mutex, but unlock the mutex.
All waiters are woken up and all subsequent calls to pthread_mutex_lock() fail to acquire the mutex. The return code is ENOTRECOVERABLE. The mutex can be made consistent by calling pthread_mutex_destroy() to unitialize the mutex, and calling pthread_mutex_int() to reinitialize it.
If the thread that acquire the lock with EOWNERDEAD died, the next owner acquires the lock with an EOWNERDEAD return code.
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: