turn POSIX's error retured into errno

man pthread_mutex_lock

RETURN VALUE
       If successful, the pthread_mutex_lock() and pthread_mutex_unlock() functions shall return zero; otherwise, an error number shall be returned to indicate the error.