MacOS X + executeFile + -threaded = "Operation not supported"
|Reported by:||PHO||Owned by:|
|Operating System:||MacOS X||Architecture:||Unknown/Multiple|
|Type of failure:||Incorrect result at runtime||Test Case:||executeFile001|
|Related Tickets:||Differential Rev(s):|
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.