add comments explaining puzzling code

This commit is contained in:
Joey Hess 2018-03-15 14:47:54 -04:00
parent ed81762c86
commit 7d83502329
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38

View file

@ -71,9 +71,13 @@ processTranscript'' cp input = do
return (transcript, code)
where
mkreader h = do
-- Start consuming the output immediately, because the
-- process may block on reading input until some
-- of its output is consumed.
s <- hGetContents h
v <- newEmptyMVar
void $ forkIO $ do
-- Wait for output to be fully consumed.
void $ E.evaluate (length s)
putMVar v ()
return $ do