[commit: ghc] master: Fix ghci crash when the user code closes stdin (b097dc9)

Ian Lynagh igloo at earth.li
Sun Jun 16 01:13:00 CEST 2013


Repository : http://darcs.haskell.org/ghc.git/

On branch  : master

https://github.com/ghc/ghc/commit/b097dc9a25f986f0a07dcd2ad1e7fdeeac63198a

>---------------------------------------------------------------

commit b097dc9a25f986f0a07dcd2ad1e7fdeeac63198a
Author: Ian Lynagh <ian at well-typed.com>
Date:   Sat Jun 15 21:54:22 2013 +0100

    Fix ghci crash when the user code closes stdin
    
    Now that we share stdin with the program, we have to check for
    handle-closed as well as EOF, as the program might have closed
    stdin.

>---------------------------------------------------------------

 ghc/InteractiveUI.hs | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/ghc/InteractiveUI.hs b/ghc/InteractiveUI.hs
index c49395d..a30410b 100644
--- a/ghc/InteractiveUI.hs
+++ b/ghc/InteractiveUI.hs
@@ -587,6 +587,11 @@ fileLoop hdl = do
    l <- liftIO $ tryIO $ hGetLine hdl
    case l of
         Left e | isEOFError e              -> return Nothing
+               | -- as we share stdin with the program, the program
+                 -- might have already closed it, so we might get a
+                 -- handle-closed exception. We therefore catch that
+                 -- too.
+                 isIllegalOperation e      -> return Nothing
                | InvalidArgument <- etype  -> return Nothing
                | otherwise                 -> liftIO $ ioError e
                 where etype = ioeGetErrorType e





More information about the ghc-commits mailing list