
13 Apr
2005
13 Apr
'05
2:53 a.m.
Simon Marlow wrote:
If you really must use hGetContents, then the hack above is necessary: you have to force the output strings before waiting for the process to terminate. This would be slightly cleaner:
res <- hGetContents outH errs <- hGetContents errH forkIO (evaluate (length res)) forkIO (evaluate (length errs))
which avoids blocking the main thread, but ensures that all the data gets pulled as it becomes available.
in
forkIO(evaluate(length res))
the types do not match. evaluate has result IO Int but forkIO expects IO (). I tried
forkIO(evaluate(length res) >> return ())
but this version again blocks. uwe