From 3312cb5906bb61b74914663535907c7d76cdfeed Mon Sep 17 00:00:00 2001 From: simonmar Date: Mon, 14 Oct 2002 14:54:16 +0000 Subject: [PATCH] [project @ 2002-10-14 14:54:16 by simonmar] Put stdin back into non-blocking mode after calling readline, because readline sometimes clears the O_NONBLOCK flag (done using the GHC.Posix interface, so it shouldn't break Win32). --- ghc/compiler/ghci/InteractiveUI.hs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ghc/compiler/ghci/InteractiveUI.hs b/ghc/compiler/ghci/InteractiveUI.hs index 8660650..686e17b 100644 --- a/ghc/compiler/ghci/InteractiveUI.hs +++ b/ghc/compiler/ghci/InteractiveUI.hs @@ -1,6 +1,6 @@ {-# OPTIONS -#include "Linker.h" -#include "SchedAPI.h" #-} ----------------------------------------------------------------------------- --- $Id: InteractiveUI.hs,v 1.134 2002/09/13 15:02:32 simonpj Exp $ +-- $Id: InteractiveUI.hs,v 1.135 2002/10/14 14:54:16 simonmar Exp $ -- -- GHC Interactive User Interface -- @@ -74,6 +74,8 @@ import Foreign ( nullPtr ) import Foreign.C.String ( CString, peekCString, withCString ) import Data.IORef ( IORef, newIORef, readIORef, writeIORef ) +import GHC.Posix ( setNonBlockingFD ) + ----------------------------------------------------------------------------- ghciWelcomeMsg = "\ @@ -319,7 +321,10 @@ readlineLoop = do cmstate <- getCmState (mod,imports) <- io (cmGetContext cmstate) io yield - l <- io (readline (mkPrompt mod imports)) + l <- io (readline (mkPrompt mod imports) + `finally` setNonBlockingFD 0) + -- readline sometimes puts stdin into blocking mode, + -- so we need to put it back for the IO library case l of Nothing -> return () Just l -> -- 1.7.10.4