Supporting fork in multithreaded programs is somewhat complicated, however in QEMU we fork in two places (daemonize and smbd) and none of them are complicated:
- daemonize happens before threads and mutexes proliferate unpredictably; only the RCU state has to be reset and the call_rcu thread recreated - smbd mostly does an exec in the child. Unfortunately, glibc also makes forking terminally incompatible with PTHREAD_MUTEX_ERRORCHECK, so you also need to disable that. Paolo Paolo Bonzini (2): qemu-thread: do not use PTHREAD_MUTEX_ERRORCHECK rcu: handle forks safely util/qemu-thread-posix.c | 6 +----- util/rcu.c | 34 +++++++++++++++++++++++++++++++++- 2 files changed, 34 insertions(+), 6 deletions(-) -- 2.3.0