[commit: ghc] master: Don translate UserInterrupt into ExitFailure 1, let it propagate (12cdd6d)

git at git.haskell.org git at git.haskell.org
Thu Nov 14 17:42:13 UTC 2013


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/12cdd6da8f6338266a30c0e274689697dea671ae/ghc

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

commit 12cdd6da8f6338266a30c0e274689697dea671ae
Author: Duncan Coutts <duncan at well-typed.com>
Date:   Thu Nov 14 16:02:03 2013 +0000

    Don translate UserInterrupt into ExitFailure 1, let it propagate
    
    It is important that if a program recieved ^C from the user, and the
    program terminates as a result, that it exit with SIGINT so that the
    parent process knows that was the case. For example cabal calling ghc
    will then be able to tell the difference between it failing and the user
    interrupting with ^C and report (or not) appropriately.
    
    So we should just let the UserInterrupt exception propagate to the top
    level error handler which will do the right thing.
    
    See http://www.cons.org/cracauer/sigint.html


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

12cdd6da8f6338266a30c0e274689697dea671ae
 compiler/main/GHC.hs |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/compiler/main/GHC.hs b/compiler/main/GHC.hs
index 5a95484..1b6ea2d 100644
--- a/compiler/main/GHC.hs
+++ b/compiler/main/GHC.hs
@@ -344,7 +344,10 @@ defaultErrorHandler fm (FlushOut flushOut) inner =
                 Just (ioe :: IOException) ->
                   fatalErrorMsg'' fm (show ioe)
                 _ -> case fromException exception of
-                     Just UserInterrupt -> exitWith (ExitFailure 1)
+                     Just UserInterrupt ->
+                         -- Important to let this one propagate out so our
+                         -- calling process knows we were interrupted by ^C
+                         liftIO $ throwIO UserInterrupt
                      Just StackOverflow ->
                          fatalErrorMsg'' fm "stack overflow: use +RTS -K<size> to increase it"
                      _ -> case fromException exception of



More information about the ghc-commits mailing list