diff options
author | Simon Marlow <marlowsd@gmail.com> | 2009-06-23 14:26:23 +0000 |
---|---|---|
committer | Simon Marlow <marlowsd@gmail.com> | 2009-06-23 14:26:23 +0000 |
commit | f540ac1cab55f5d4a61e5b1e22ef48d92a7b1cfe (patch) | |
tree | 1a8a19104cf2e5b15609546848f7d992ee3db8e0 /ghc | |
parent | 0fb9ad3a5e363ec2c7676d91037678ee33f496b7 (diff) | |
download | haskell-f540ac1cab55f5d4a61e5b1e22ef48d92a7b1cfe.tar.gz |
Fix buffering problem when GHCi is using the new IO library
Behind the scenes, the new IO library always does buffering for read
Handles regardless of NoBuffering. Normally this isn't visible, but
it causes a problem in GHCi where there are two stdin Handles.
This should fix those ghci test failures that sprung up in full
testsuite runs recently.
Diffstat (limited to 'ghc')
-rw-r--r-- | ghc/InteractiveUI.hs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/ghc/InteractiveUI.hs b/ghc/InteractiveUI.hs index 82c9aab84c..0e9efb67c5 100644 --- a/ghc/InteractiveUI.hs +++ b/ghc/InteractiveUI.hs @@ -96,6 +96,7 @@ import GHC.Exts ( unsafeCoerce# ) #if __GLASGOW_HASKELL__ >= 611 import GHC.IO.Exception ( IOErrorType(InvalidArgument) ) +import GHC.IO.Handle ( hFlushAll ) #else import GHC.IOBase ( IOErrorType(InvalidArgument) ) #endif @@ -636,7 +637,16 @@ runStmt stmt step | null (filter (not.isSpace) stmt) = return False | ["import", mod] <- words stmt = keepGoing' setContext ('+':mod) | otherwise - = do result <- GhciMonad.runStmt stmt step + = do +#if __GLASGOW_HASKELL__ >= 611 + -- In the new IO library, read handles buffer data even if the Handle + -- is set to NoBuffering. This causes problems for GHCi where there + -- are really two stdin Handles. So we flush any bufferred data in + -- GHCi's stdin Handle here (only relevant if stdin is attached to + -- a file, otherwise the read buffer can't be flushed). + liftIO $ IO.try $ hFlushAll stdin +#endif + result <- GhciMonad.runStmt stmt step afterRunStmt (const True) result --afterRunStmt :: GHC.RunResult -> GHCi Bool |