wrap Main.main in GHC.TopHandler.runIOFastExit
authorSimon Marlow <simonmar@microsoft.com>
Fri, 5 Jan 2007 11:46:08 +0000 (11:46 +0000)
committerSimon Marlow <simonmar@microsoft.com>
Fri, 5 Jan 2007 11:46:08 +0000 (11:46 +0000)
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

index f8330b5..1d4907d 100644 (file)
@@ -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))
                        "-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
          exitWith res
 
 notArg ('-':_) = False