From eeb486bd483bdf707d009f727705d856d50fa88d Mon Sep 17 00:00:00 2001
From: Jacques Garrigue <garrigue at math.nagoya-u.ac.jp>
Date: Tue, 2 Oct 2001 03:09:38 +0000
Subject: create new console if not available

git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@3821 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
---
 otherlibs/win32unix/createprocess.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

(limited to 'otherlibs/win32unix/createprocess.c')

diff --git a/otherlibs/win32unix/createprocess.c b/otherlibs/win32unix/createprocess.c
index 6e84c78da..a99af4036 100644
--- a/otherlibs/win32unix/createprocess.c
+++ b/otherlibs/win32unix/createprocess.c
@@ -39,15 +39,18 @@ value win_create_process_native(value cmd, value cmdline, value env,
   si.hStdInput = Handle_val(fd1);
   si.hStdOutput = Handle_val(fd2);
   si.hStdError = Handle_val(fd3);
-  /* If we do not have a console window, then we must run
-     console mode applications as detached processes.
+  /* If we do not have a console window, then we must create one
+     before running the process (keep it hidden for apparence).
      Otherwise, a new console is created and the redirections
      are ignored.  If we're running a GUI application, the
-     detached / non-detached flag doesn't matter. */
+     newly created console doesn't matter. */
   if (win_has_console())
     flags = 0;
-  else
-    flags = DETACHED_PROCESS;
+  else {
+    flags = CREATE_NEW_CONSOLE;
+    si.dwFlags |= STARTF_USESHOWWINDOW;
+    si.wShowWindow = SW_HIDE;
+  }
   /* Create the process */
   if (! CreateProcess(exefile, String_val(cmdline), NULL, NULL,
                       TRUE, flags, envp, NULL, &si, &pi)) {
-- 
cgit v1.2.3-70-g09d2