[project @ 2005-03-14 15:57:57 by simonmar]
[ghc-base.git] / GHC / TopHandler.lhs
index 7e5bca4..b1ac1b8 100644 (file)
@@ -14,6 +14,7 @@
 --
 -----------------------------------------------------------------------------
 
+-- #hide
 module GHC.TopHandler (
    runMainIO, runIO, runNonIO, reportStackOverflow, reportError
   ) where
@@ -58,14 +59,15 @@ topHandler err = catchException (real_handler err) topHandler
 --
 real_handler :: Exception -> IO a
 real_handler ex =
+  cleanUp >>
   case ex of
        AsyncException StackOverflow -> do
           reportStackOverflow
           safeExit 2
 
        -- only the main thread gets ExitException exceptions
-       ExitException ExitSuccess     -> cleanUp >> safeExit 0
-       ExitException (ExitFailure n) -> cleanUp >> safeExit n
+       ExitException ExitSuccess     -> safeExit 0
+       ExitException (ExitFailure n) -> safeExit n
 
        other -> do
           reportError other