diff options
Diffstat (limited to 'driver')
-rw-r--r-- | driver/gcc/gcc.c | 2 | ||||
-rw-r--r-- | driver/ghc/ghc.c | 2 | ||||
-rw-r--r-- | driver/ghci/ghc.mk | 4 | ||||
-rw-r--r-- | driver/ghci/ghci.c | 13 | ||||
-rw-r--r-- | driver/haddock/haddock.c | 2 | ||||
-rw-r--r-- | driver/utils/cwrapper.c | 9 | ||||
-rw-r--r-- | driver/utils/cwrapper.h | 6 | ||||
-rw-r--r-- | driver/utils/dynwrapper.c | 1 |
8 files changed, 28 insertions, 11 deletions
diff --git a/driver/gcc/gcc.c b/driver/gcc/gcc.c index b398c5ea46..aa63bb0498 100644 --- a/driver/gcc/gcc.c +++ b/driver/gcc/gcc.c @@ -61,6 +61,6 @@ int main(int argc, char** argv) { preArgv[2] = mkString("-B%s/../lib/gcc/%s/%s" , binDir, base, version); preArgv[3] = mkString("-B%s/../libexec/gcc/%s/%s", binDir, base, version); - run(exePath, 4, preArgv, argc - 1, argv + 1); + run(exePath, 4, preArgv, argc - 1, argv + 1, NULL); } diff --git a/driver/ghc/ghc.c b/driver/ghc/ghc.c index 67f8f26860..416f4ba1a4 100644 --- a/driver/ghc/ghc.c +++ b/driver/ghc/ghc.c @@ -10,5 +10,5 @@ int main(int argc, char** argv) { binDir = getExecutablePath(); exePath = mkString("%s/ghc.exe", binDir); - run(exePath, 0, NULL, argc - 1, argv + 1); + run(exePath, 0, NULL, argc - 1, argv + 1, NULL); } diff --git a/driver/ghci/ghc.mk b/driver/ghci/ghc.mk index 0f31884080..0e18a5fbbd 100644 --- a/driver/ghci/ghc.mk +++ b/driver/ghci/ghc.mk @@ -21,7 +21,7 @@ install_driver_ghci: $(INSTALL_DIR) "$(DESTDIR)$(bindir)" $(call removeFiles, "$(WRAPPER)") $(CREATE_SCRIPT) "$(WRAPPER)" - echo '#!$(SHELL)' >> "$(WRAPPER)" + echo '#!/bin/sh' >> "$(WRAPPER)" echo 'exec "$(bindir)/$(CrossCompilePrefix)ghc-$(ProjectVersion)" --interactive "$$@"' >> "$(WRAPPER)" $(EXECUTABLE_FILE) "$(WRAPPER)" $(call removeFiles,"$(DESTDIR)$(bindir)/$(CrossCompilePrefix)ghci") @@ -56,7 +56,7 @@ install_driver_ghcii: GHCII_SCRIPT_VERSIONED = $(DESTDIR)$(bindir)/ghcii-$(Proje install_driver_ghcii: $(INSTALL_DIR) "$(DESTDIR)$(bindir)" $(call removeFiles,"$(GHCII_SCRIPT)") - echo "#!$(SHELL)" >> $(GHCII_SCRIPT) + echo "#!/bin/sh" >> $(GHCII_SCRIPT) echo 'exec "$$(dirname "$$0")"/ghc --interactive "$$@"' >> $(GHCII_SCRIPT) $(EXECUTABLE_FILE) $(GHCII_SCRIPT) cp $(GHCII_SCRIPT) $(GHCII_SCRIPT_VERSIONED) diff --git a/driver/ghci/ghci.c b/driver/ghci/ghci.c index ebf13d8ba7..a603655ec8 100644 --- a/driver/ghci/ghci.c +++ b/driver/ghci/ghci.c @@ -11,6 +11,16 @@ BOOL fileExists(const char *path) { return r != INVALID_FILE_ATTRIBUTES && !(r & FILE_ATTRIBUTE_DIRECTORY); } +/* In order for this console program to pass on full event processing to called + process we need to remove it from the current console. Since we want the + child to inherit the handles so redirection etc all work we need to detach + from the console after the child has been created. However we don't want to + detach from the console in non-interactive scenarios otherwise we'll hit + #13411 again. So we only detach when we're sure we need to, see #14150. */ +void ReleaseResource(void) { + FreeConsole(); +} + int main(int argc, char** argv) { char *binDir; char *exePath; @@ -33,6 +43,5 @@ int main(int argc, char** argv) { exePath = mkString("%s/ghc-stage2.exe", binDir); } - run(exePath, 1, preArgv, argc - 1, argv + 1); + run(exePath, 1, preArgv, argc - 1, argv + 1, ReleaseResource); } - diff --git a/driver/haddock/haddock.c b/driver/haddock/haddock.c index e43d33f046..79ab873791 100644 --- a/driver/haddock/haddock.c +++ b/driver/haddock/haddock.c @@ -10,5 +10,5 @@ int main(int argc, char** argv) { binDir = getExecutablePath(); exePath = mkString("%s/haddock.exe", binDir); - run(exePath, 0, NULL, argc - 1, argv + 1); + run(exePath, 0, NULL, argc - 1, argv + 1, NULL); } diff --git a/driver/utils/cwrapper.c b/driver/utils/cwrapper.c index 5a30274ba7..522c2b329a 100644 --- a/driver/utils/cwrapper.c +++ b/driver/utils/cwrapper.c @@ -70,9 +70,12 @@ char *flattenAndQuoteArgs(char *ptr, int argc, char *argv[]) return ptr; } +/* This function takes a callback to be called after the creation of the child + process but before we block waiting for the child. Can be NULL. */ __attribute__((noreturn)) int run (char *exePath, int numArgs1, char **args1, - int numArgs2, char **args2) + int numArgs2, char **args2, + runCallback callback) { int i, cmdline_len; char *new_cmdline, *ptr; @@ -134,6 +137,10 @@ __attribute__((noreturn)) int run (char *exePath, /* Synchronize input and wait for target to be ready. */ WaitForInputIdle(pi.hProcess, INFINITE); + /* If we have a registered callback then call it before we block. */ + if (callback) + callback(); + switch (WaitForSingleObject(pi.hProcess, INFINITE) ) { case WAIT_OBJECT_0: { diff --git a/driver/utils/cwrapper.h b/driver/utils/cwrapper.h index 324470e5ed..3e9ccd4fe5 100644 --- a/driver/utils/cwrapper.h +++ b/driver/utils/cwrapper.h @@ -1,5 +1,7 @@ void die(const char *fmt, ...); char *mkString(const char *fmt, ...); -__attribute__((noreturn)) int run(char *exePath, int numArgs1, char **args1, int numArgs2, char **args2); - +typedef void (*runCallback)(void); +__attribute__((noreturn)) int run(char *exePath, int numArgs1, char **args1, + int numArgs2, char **args2, + runCallback callback); diff --git a/driver/utils/dynwrapper.c b/driver/utils/dynwrapper.c index a9250f58ba..7fb06e5945 100644 --- a/driver/utils/dynwrapper.c +++ b/driver/utils/dynwrapper.c @@ -155,7 +155,6 @@ HINSTANCE GetNonNullModuleHandle(LPTSTR dll) { typedef int (*hs_main_t)(int , char **, StgClosure *, RtsConfig); int main(int argc, char *argv[]) { - void *p; HINSTANCE hRtsDll, hProgDll; LPTSTR oldPath; |