On linux with copy-on-write forking. When creating pthread interprocess mutex in a parent, will it be effective in the child or it will work so only if I mmap it into shared memory?
On linux with copy-on-write forking. When creating pthread interprocess mutex in a parent, will
Share
When calling
fork()the whole memory space is duplicated, including mutexes, so to answer your question, the new mutex will be a copy of the parent’s mutex, so you have tommapit.Note:
You will need to set the
PTHREAD_PROCESS_SHAREDflag on the mutex attribute usingpthread_mutexattr_getpshared().