Flushing stdout to solve infinite loop (#542).

This commit is contained in:
Kazu Yamamoto 2015-08-19 15:02:00 +09:00
parent bb3a948912
commit b7cea06a52

View File

@ -129,13 +129,14 @@ stdoutGateway chan = go ("", "")
case ty of case ty of
GmTerminated -> GmTerminated ->
case stream of case stream of
GmOut -> putStr (obuf++l) >> go ("", ebuf) GmOut -> putStr (obuf++l) >> hFlush stdout >> go ("", ebuf)
GmErr -> putStr (ebuf++l) >> go (obuf, "") GmErr -> putStr (ebuf++l) >> hFlush stdout >> go (obuf, "")
GmPartial -> case reverse $ lines l of GmPartial -> case reverse $ lines l of
[] -> go buf [] -> go buf
[x] -> go (appendBuf stream buf x) [x] -> go (appendBuf stream buf x)
x:xs -> do x:xs -> do
putStr $ unlines $ reverse xs putStr $ unlines $ reverse xs
hFlush stdout
go (appendBuf stream buf x) go (appendBuf stream buf x)
appendBuf GmOut (obuf, ebuf) s = (obuf++s, ebuf) appendBuf GmOut (obuf, ebuf) s = (obuf++s, ebuf)