I\'m working with a web server project that performs a fork
without an exec
. The program depends upon OpenSSL, and OpenSSL needs a number of locks (
The mutexes won't be valid across the fork
unless you put them in shared memory and initialize the mutex attribute with pthread_mutexattr_setpshared
set to PTHREAD_PROCESS_SHARED.
It's not clear if you are forking and then creating threads or creating the threads and then forking. If the latter, then fork will only apply to the thread that calls fork. None of the other threads are created in the new process.
If you are forking and then threading and the mutexes are meant to only apply to the child process and its threads then just create them after the fork.