
Well, hPipeFrom does indeed call forkProcess internally. I don't fully
understand when it is and is not safe to use 'forkProcess' with the
threaded runtime of GHC.
Which version of GHC are you using?
Antoine
On Sat, Jul 14, 2012 at 1:24 PM, Joey Hess
I've found a minimal test case that seems to demonstrate a bug in either MissingH or ghc's threaded runtime. Or I'm doing something stupid in fewer lines of code than usual. ;)
When built with the threaded runtime, after a short while it hangs in hGetContents.
import System.Cmd import System.IO import System.Cmd.Utils import System.Posix.Process import Control.Monad
main :: IO () main = forever $ pipeRead ["hello", "world"]
pipeRead :: [String] -> IO () pipeRead params = do -- removing this next line avoids the hang somehow print $ "pipeRead in " ++ show params (p, h) <- hPipeFrom "echo" params print "pipeRead getcontents" c <- hGetContents h print $ "got: " ++ c _ <- getProcessStatus True False $ processID p -- removing this last line avoids the hang somehow print "pipeRead out"
joey@wren:~>ghc --make -threaded test [1 of 1] Compiling Main ( test.hs, test.o ) Linking test ... joey@wren:~>./test "pipeRead in [\"hello\",\"world\"]" "pipeRead getcontents" "got: hello world\n" "pipeRead out" "pipeRead in [\"hello\",\"world\"]" "pipeRead getcontents" "got: hello world\n" "pipeRead out"
"pipeRead in [\"hello\",\"world\"]" "pipeRead getcontents" <hang> Ghc 7.4.2, Debian Linux
-- see shy jo
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe