summaryrefslogtreecommitdiff
path: root/driver/utils
diff options
context:
space:
mode:
authorTamar Christina <tamar@zhox.com>2017-09-26 19:43:15 +0100
committerTamar Christina <tamar@zhox.com>2017-09-26 19:43:15 +0100
commit3ec579d5d13dd00af58380a34daa2d57f0b9aa9e (patch)
tree17a3c921cdf6d85a5e4ad1d17d90c6707c16bad4 /driver/utils
parentf9f1e38c204c0d294d31398c8c300fba3d89f450 (diff)
downloadhaskell-3ec579d5d13dd00af58380a34daa2d57f0b9aa9e.tar.gz
Release console for ghci wrapper
Summary: It seems the call that caused issues with the gcc wrapper before was needed for the ghci wrapper in order for the child process to be the one handling console events. This code slightly refactors the wrappers to make sure only ghci calls FreeConsole and nothing else. Test Plan: ./validate , open ghci.exe press ctrl+c Reviewers: RyanGlScott, austin, hvr, bgamari Reviewed By: bgamari Subscribers: rwbarton, thomie, erikd GHC Trac Issues: #14150 Differential Revision: https://phabricator.haskell.org/D4028
Diffstat (limited to 'driver/utils')
-rw-r--r--driver/utils/cwrapper.c9
-rw-r--r--driver/utils/cwrapper.h6
2 files changed, 12 insertions, 3 deletions
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);