MacOS X + executeFile + -threaded = "Operation not supported"
Mac OS X has an undocumented behavior concerning 'execve(2)' inside a threaded process. If a process tries to call 'execve(2)' and has more than one native thread, the kernel returns 'EOPNOTSUPP'. This prevents 'executeFile' from working when the threaded runtime is used.
% ghci GHCi, version 7.0.3: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer-gmp ... linking ... done. Loading package base ... linking ... done. Loading package ffi-1.0 ... linking ... done. Prelude> System.Posix.Process.executeFile "/bin/sh" False  Nothing Loading package unix-126.96.36.199 ... linking ... done. *** Exception: /bin/sh: executeFile: failed (Operation not supported) Prelude> Leaving GHCi. % uname Darwin
To work around this, we have to 'fork(2)' before calling 'execve(2)', to make sure there is only a single active thread.