From 7afd995197924dc6d650b51e160755d651ad1e0d Mon Sep 17 00:00:00 2001 From: Simon Marlow Date: Fri, 5 Jan 2007 11:46:08 +0000 Subject: [PATCH] wrap Main.main in GHC.TopHandler.runIOFastExit This is so that exceptions raised by Main.main do exactly the same thing as they would in a compiled program, including writing the message to stderr and shutting down with the correct exit code. --- utils/runghc/runghc.hs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/utils/runghc/runghc.hs b/utils/runghc/runghc.hs index f8330b5..1d4907d 100644 --- a/utils/runghc/runghc.hs +++ b/utils/runghc/runghc.hs @@ -53,7 +53,13 @@ doIt ghc args = do "-ignore-dot-ghci" : ghc_args ++ [ "-e","System.Environment.withProgName "++show filename++" (System.Environment.withArgs [" ++ concat (intersperse "," (map show prog_args)) - ++ "] Main.main)", filename]) + ++ "] (GHC.TopHandler.runIOFastExit Main.main))", filename]) + -- runIOFastExit: makes exceptions raised by Main.main + -- behave in the same way as for a compiled program. + -- The "fast exit" part just calls exit() directly + -- instead of doing an orderly runtime shutdown, + -- otherwise the main GHCi thread will complain about + -- being interrupted. exitWith res notArg ('-':_) = False -- 1.7.10.4