Commit 97a48d1a authored by Simon Marlow's avatar Simon Marlow
Browse files

rawSystemStdout': do hGetContents synchonously, to avoid a race condition

parent 4eb65a26
......@@ -259,7 +259,11 @@ rawSystemStdout' verbosity path args = do
-- fork off a thread to pull on (and discard) the stderr
-- so if the process writes to stderr we do not block.
forkIO $ hGetContents errh >>= evaluate . length >> return ()
-- NB. do the hGetContents synchronously, otherwise the outer
-- bracket can exit before this thread has run, and hGetContents
-- will fail.
err <- hGetContents errh
forkIO $ do evaluate (length err); return ()
-- wait for all the output
output <- hGetContents outh
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment