diff options
author | Simon Marlow <simonmar@microsoft.com> | 2006-09-28 10:54:03 +0000 |
---|---|---|
committer | Simon Marlow <simonmar@microsoft.com> | 2006-09-28 10:54:03 +0000 |
commit | bd6cfcc12e3a047b1fd6d62cf79ea2cc2bd010b9 (patch) | |
tree | c885936182676c3483493bcf912f4aa071dd05fa /compiler/ghci | |
parent | 02c891a4616f984e3d052bb0601f97159d8ad605 (diff) | |
download | haskell-bd6cfcc12e3a047b1fd6d62cf79ea2cc2bd010b9.tar.gz |
only make stdin/stdout unbuffered in GHCi, not runghc or ghc -e.
Diffstat (limited to 'compiler/ghci')
-rw-r--r-- | compiler/ghci/InteractiveUI.hs | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/compiler/ghci/InteractiveUI.hs b/compiler/ghci/InteractiveUI.hs index 02fc10c767..485e329d39 100644 --- a/compiler/ghci/InteractiveUI.hs +++ b/compiler/ghci/InteractiveUI.hs @@ -84,7 +84,7 @@ import Data.Dynamic import Numeric import Data.List import Data.Int ( Int64 ) -import Data.Maybe ( isJust, fromMaybe, catMaybes ) +import Data.Maybe ( isJust, isNothing, fromMaybe, catMaybes ) import System.Cmd import System.CPUTime import System.Environment @@ -274,15 +274,19 @@ interactiveUI session srcs maybe_expr = do newStablePtr stdout newStablePtr stderr - hFlush stdout - hSetBuffering stdout NoBuffering - -- Initialise buffering for the *interpreted* I/O system initInterpBuffering session + when (isNothing maybe_expr) $ do + -- Only for GHCi (not runghc and ghc -e): + -- Turn buffering off for the compiled program's stdout/stderr + turnOffBuffering + -- Turn buffering off for GHCi's stdout + hFlush stdout + hSetBuffering stdout NoBuffering -- We don't want the cmd line to buffer any input that might be -- intended for the program, so unbuffer stdin. - hSetBuffering stdin NoBuffering + hSetBuffering stdin NoBuffering -- initial context is just the Prelude prel_mod <- GHC.findModule session prel_name Nothing @@ -649,8 +653,6 @@ initInterpBuffering session Just hval -> writeIORef flush_interp (unsafeCoerce# hval :: IO ()) _ -> panic "interactiveUI:flush" - turnOffBuffering -- Turn it off right now - return () |