[Haskell-cafe] forkProcess, forkIO, and multithreaded runtime

Richard O'Keefe ok at cs.otago.ac.nz
Tue Oct 16 23:47:49 CEST 2012

The problems with forkProcess really are not Haskell's fault.
You will find warnings in the documentation for C's fork():

	There are limits to what you can do in the child process.
	To be totally safe you should restrict yourself to only
	executing async-signal safe operations until such time
	as one of the exec functions is called.  All APIs,
	including global data symbols, in any framework or
	library should be assumed to be unsafe after a fork()
	unless explicitly documented to be safe or async-signal safe.

That's actually pretty scary.  I'd always assumed that this was
one of the reasons why the posix_spawn() function and its support
crew were devised.  Which reminds me that I expected to find
posix_spawn() in System.Posix.Process but didn't.


More information about the Haskell-Cafe mailing list