X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=utils%2Frunghc%2Frunghc.hs;h=cdf06dc33f8294857b49b1a7ea5dd5e566304368;hb=a966047ca5c407f336a633d716d3d7b5ed29d231;hp=f8330b5721363fb540cced05355d274dda3c69cb;hpb=0065d5ab628975892cea1ec7303f968c3338cbe1;p=ghc-hetmet.git diff --git a/utils/runghc/runghc.hs b/utils/runghc/runghc.hs index f8330b5..cdf06dc 100644 --- a/utils/runghc/runghc.hs +++ b/utils/runghc/runghc.hs @@ -28,8 +28,13 @@ import Data.List import System.Exit import Data.Char -import Compat.RawSystem ( rawSystem ) -import Compat.Directory ( findExecutable ) +#ifdef USING_COMPAT +import Compat.RawSystem ( rawSystem ) +import Compat.Directory ( findExecutable ) +#else +import System.Cmd ( rawSystem ) +import System.Directory ( findExecutable ) +#endif main = do args <- getArgs @@ -53,7 +58,17 @@ 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 Prelude.>> (Prelude.return ()))))", 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. + -- + -- Why (main >> return ()) rather than just main? Because + -- otherwise GHCi by default tries to evaluate the result + -- of the IO in order to show it (see #1200). exitWith res notArg ('-':_) = False