Do pthread mutexes work across threads if in shared memory?

You need to tell the mutex to be process-shared when it’s inited:

http://www.opengroup.org/onlinepubs/007908775/xsh/pthread_mutexattr_setpshared.html

Note in particular, “The default value of the attribute is PTHREAD_PROCESS_PRIVATE”, meaning that accessing it from different processes is undefined behaviour.

Leave a Comment