summaryrefslogtreecommitdiff
path: root/compiler/main
diff options
context:
space:
mode:
authorSylvain HENRY <hsyl20@gmail.com>2016-11-02 14:55:06 -0400
committerBen Gamari <ben@smart-cactus.org>2016-11-02 14:55:07 -0400
commit8a5960ad874d31fcf631b4d427ccd9fae571745c (patch)
tree084ebb82c66de2fd4ac44591e3b6918baad0c044 /compiler/main
parent623b8e44b1647083ff5d85ef40b7cf88870acef5 (diff)
downloadhaskell-8a5960ad874d31fcf631b4d427ccd9fae571745c.tar.gz
Uninstall signal handlers
GHC installs signal handlers in runGhc/runGhcT to handle ^C but it never uninstalls them. It can be an issue, especially when using GHC as a library. Test Plan: validate Reviewers: bgamari, erikd, austin, simonmar Reviewed By: bgamari, simonmar Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2633 GHC Trac Issues: #4162
Diffstat (limited to 'compiler/main')
-rw-r--r--compiler/main/GHC.hs10
1 files changed, 3 insertions, 7 deletions
diff --git a/compiler/main/GHC.hs b/compiler/main/GHC.hs
index 5122329acf..8eb77efe2d 100644
--- a/compiler/main/GHC.hs
+++ b/compiler/main/GHC.hs
@@ -13,7 +13,7 @@ module GHC (
defaultErrorHandler,
defaultCleanupHandler,
prettyPrintGhcErrors,
- installSignalHandlers,
+ withSignalHandlers,
withCleanupSession,
-- * GHC Monad
@@ -438,13 +438,10 @@ runGhc :: Maybe FilePath -- ^ See argument to 'initGhcMonad'.
runGhc mb_top_dir ghc = do
ref <- newIORef (panic "empty session")
let session = Session ref
- flip unGhc session $ do
- liftIO installSignalHandlers -- catch ^C
+ flip unGhc session $ withSignalHandlers $ do -- catch ^C
initGhcMonad mb_top_dir
withCleanupSession ghc
- -- XXX: unregister interrupt handlers here?
-
-- | Run function for 'GhcT' monad transformer.
--
-- It initialises the GHC session and warnings via 'initGhcMonad'. Each call
@@ -458,8 +455,7 @@ runGhcT :: ExceptionMonad m =>
runGhcT mb_top_dir ghct = do
ref <- liftIO $ newIORef (panic "empty session")
let session = Session ref
- flip unGhcT session $ do
- liftIO installSignalHandlers -- catch ^C
+ flip unGhcT session $ withSignalHandlers $ do -- catch ^C
initGhcMonad mb_top_dir
withCleanupSession ghct