The pthread_mutex_init() function shall fail if:
EAGAIN
The system lacked the necessary resources (other than
memory) to initialize another mutex.
ENOMEM
Insufficient memory exists to initialize the mutex.
EPERM
The caller does not have the privilege to perform the
operation.
The pthread_mutex_init() function may fail if:
EINVAL
The attributes object referenced by attr has the robust
mutex attribute set without the process-shared attribute
being set.
These functions shall not return an error code of [EINTR]
.
The following sections are informative.