This PR is to help fix merijn/posix-pty#15.
Summary: on Posix systems, System.Process must take certain precautions before using the fork system call. These include altering global state by calling blockUserSignals and stopTimer() before forking; see https://github.com/haskell/process/blob/master/cbits/runProcess.c#L137.
However, System.Process is not the only library that might need to use fork. System.Posix.Pty is another such library -- it uses the forkpty call (which internally does fork) to create a process attached to a pseudo-terminal. Thus System.Posix.Pty also needs to take these precautions.
As a result, we need to ensure mutual exclusion between System.Posix.Pty fork calls and System.Process fork calls, or else they stomp on each other's changes to global state. The only way I can see to do this is to use the same lock, so this PR exports it. I made a PR on posix-pty to leverage it here: merijn/posix-pty#16.
Of course, this feels like a bit of a band-aid since it only ensures that interleaving these two libraries is safe. Other libraries that might want to fork will still run into problems interleaving with these libraries. It would be nice to get some GHC expert attention on this but maybe that's an issue for another tracker.