From 195bfbf0f5ab63520817fe0661d23952cf852ec1 Mon Sep 17 00:00:00 2001 From: Michael Snoyman Date: Thu, 11 Aug 2016 13:40:03 +0300 Subject: [PATCH] Replace runghc with ghc -e Main.main Motivation: if you call `runghc`, that process continues to live on separate from the actual `ghc` process that interprets the code. That's inefficient. But more worryingly: the `runghc` process itself can cause major problems in Docker images, since it ends up swallowing SIGINTs as the PID-1 process. This was discussed quite a bit on Twitter: https://twitter.com/argumatronic/status/763418990982991872 --- src/main/Main.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/Main.hs b/src/main/Main.hs index 3f81121fa2..176fc4b3a8 100644 --- a/src/main/Main.hs +++ b/src/main/Main.hs @@ -715,7 +715,7 @@ execCmd ExecOpts {..} go@GlobalOpts{..} = (cmd, args) <- case (eoCmd, eoArgs) of (ExecCmd cmd, args) -> return (cmd, args) (ExecGhc, args) -> return ("ghc", args) - (ExecRunGhc, args) -> return ("runghc", args) + (ExecRunGhc, args) -> return ("ghc", "-e" : "Main.main" : args) (manager,lc) <- liftIO $ loadConfigWithOpts go withUserFileLock go (configStackRoot $ lcConfig lc) $ \lk -> do compilerVersion <- loadCompilerVersion manager go lc @@ -742,7 +742,7 @@ execCmd ExecOpts {..} go@GlobalOpts{..} = (ExecGhc, args) -> execCompiler "" args -- NOTE: this won't currently work for GHCJS, because it doesn't have -- a runghcjs binary. It probably will someday, though. - (ExecRunGhc, args) -> execCompiler "run" args + (ExecRunGhc, args) -> execCompiler "" ("-e" : "Main.main" : args) let targets = concatMap words eoPackages unless (null targets) $ Stack.Build.build (const $ return ()) lk defaultBuildOptsCLI