The return from pthread_mutex_lock is an errno value; how about using the usual function to map that to an error text, instead of the less intelligible number ?