From b097dc9a25f986f0a07dcd2ad1e7fdeeac63198a Mon Sep 17 00:00:00 2001 From: Ian Lynagh Date: Sat, 15 Jun 2013 21:54:22 +0100 Subject: [PATCH] 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 c49395db3346..a30410b6a81f 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