Skip to content

Commit

Permalink
Fix ghci crash when the user code closes stdin
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Ian Lynagh committed Jun 15, 2013
1 parent 75947bb commit b097dc9
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ghc/InteractiveUI.hs
Expand Up @@ -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
Expand Down

0 comments on commit b097dc9

Please sign in to comment.