|Title||fork() unsupported on FreeBSD, Linux and macOS|
|Assigned user||Gareth Rees|
|Description||Christian Schafmeister would like to be able to call fork() in a process that is running the MPS . The problems with this are:|
1. The MPS might be holding a lock in thread B when the fork() occurs in thread A. This lock would never be released, since the child process only has a fork of thread A.
2. On OS X, the MPS starts a thread whose job is to handle memory protection exceptions; after fork(), this thread won’t be running in the child so memory protection exceptions will not be handled. See protxc.c.
|Analysis||For problem (2), the MPS on OS X could call pthread_atfork with a "child" handler that restarts the exception handler thread.|
For problem (1), the MPS would have to claim all the locks in the "prepare" handler and then release them in the "parent" and "child" handlers. (The pthread_atfork POSIX specification recommends this approach explicitly: "The expected usage is that the prepare handler acquires all mutex locks and the other two fork handlers release them.")
|Created by||Gareth Rees|
|Created on||2018-06-12 17:18:10|
|Last modified by||Gareth Rees|
|Last modified on||2018-06-15 11:41:32|
|History||2018-06-12 GDR Created.|
|193816||closed||2018-06-15 11:41:32||Gareth Rees||Merge branch/2018-06-13/fork.|