summaryrefslogtreecommitdiff
path: root/ghc
diff options
context:
space:
mode:
authorIan Lynagh <ian@well-typed.com>2013-06-15 21:54:22 +0100
committerIan Lynagh <ian@well-typed.com>2013-06-15 21:54:22 +0100
commitb097dc9a25f986f0a07dcd2ad1e7fdeeac63198a (patch)
tree8d8090cf3b88cceec60ca857f31f804d95c7bdcf /ghc
parent75947bb63794cae5950f679c8df86441b736b3fa (diff)
downloadhaskell-b097dc9a25f986f0a07dcd2ad1e7fdeeac63198a.tar.gz
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.
Diffstat (limited to 'ghc')
-rw-r--r--ghc/InteractiveUI.hs5
1 files changed, 5 insertions, 0 deletions
diff --git a/ghc/InteractiveUI.hs b/ghc/InteractiveUI.hs
index c49395db33..a30410b6a8 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