This commit is contained in:
Yevgen Muntyan 2008-05-17 16:54:08 -05:00
parent 74371d5c96
commit 8a0de93562

View File

@ -1,32 +1,18 @@
Index: glib/gspawn.h
===================================================================
--- glib/gspawn.h (revision 6301)
+++ glib/gspawn.h (working copy)
@@ -67,6 +67,9 @@ typedef enum
G_SPAWN_STDERR_TO_DEV_NULL = 1 << 4,
G_SPAWN_CHILD_INHERITS_STDIN = 1 << 5,
G_SPAWN_FILE_AND_ARGV_ZERO = 1 << 6
+#ifdef G_OS_WIN32
+ , G_SPAWN_WIN32_HIDDEN_CONSOLE = 1 << 7
+#endif
} GSpawnFlags;
GQuark g_spawn_error_quark (void);
Index: glib/gspawn-win32.c
===================================================================
--- glib/gspawn-win32.c (revision 6301)
--- glib/gspawn-win32.c (revision 6898)
+++ glib/gspawn-win32.c (working copy)
@@ -95,7 +95,8 @@ enum
@@ -88,7 +88,8 @@ enum
};
enum {
- ARG_CHILD_ERR_REPORT = 1,
+ ARG_HANDLES_IN_ARGV = 1,
+ ARG_CHILD_ERR_REPORT,
ARG_HELPER_SYNC,
ARG_STDIN,
ARG_STDOUT,
ARG_STDERR,
@@ -334,7 +335,11 @@ read_helper_report (int fd,
@@ -346,7 +347,11 @@ read_helper_report (int fd,
}
if (bytes < sizeof(gint)*2)
@ -39,7 +25,7 @@ Index: glib/gspawn-win32.c
return TRUE;
}
@@ -500,6 +505,60 @@ do_spawn_directly (gint
@@ -512,6 +517,60 @@ do_spawn_directly (gint
return TRUE;
}
@ -100,18 +86,17 @@ Index: glib/gspawn-win32.c
static gboolean
do_spawn_with_pipes (gint *exit_status,
gboolean do_return_handle,
@@ -534,7 +593,9 @@ do_spawn_with_pipes (gint
gchar *helper_process;
CONSOLE_CURSOR_INFO cursor_info;
wchar_t *whelper, **wargv, **wenvp;
-
@@ -550,6 +609,9 @@ do_spawn_with_pipes (gint
extern gchar *_glib_get_installation_directory (void);
gchar *glib_top;
+ gboolean error_set = FALSE;
+ gboolean handles_in_argv = FALSE;
+
SETUP_DEBUG();
if (child_setup && !warned_about_child_setup)
@@ -546,6 +607,7 @@ do_spawn_with_pipes (gint
{
warned_about_child_setup = TRUE;
@@ -559,6 +621,7 @@ do_spawn_with_pipes (gint
argc = protect_argv (argv, &protected_argv);
if (!standard_input && !standard_output && !standard_error &&
@ -119,7 +104,7 @@ Index: glib/gspawn-win32.c
(flags & G_SPAWN_CHILD_INHERITS_STDIN) &&
!(flags & G_SPAWN_STDOUT_TO_DEV_NULL) &&
!(flags & G_SPAWN_STDERR_TO_DEV_NULL) &&
@@ -575,12 +637,21 @@ do_spawn_with_pipes (gint
@@ -591,7 +654,8 @@ do_spawn_with_pipes (gint
goto cleanup_and_fail;
new_argv = g_new (char *, argc + 1 + ARG_COUNT);
@ -129,8 +114,11 @@ Index: glib/gspawn-win32.c
helper_process = HELPER_PROCESS "-console.exe";
else
helper_process = HELPER_PROCESS ".exe";
new_argv[0] = helper_process;
- _g_sprintf (args[ARG_CHILD_ERR_REPORT], "%d", child_err_report_pipe[1]);
@@ -608,7 +672,15 @@ do_spawn_with_pipes (gint
new_argv[0] = protect_argv_string (helper_process);
_g_sprintf (args[ARG_CHILD_ERR_REPORT], "%d", child_err_report_pipe[1]);
- new_argv[ARG_CHILD_ERR_REPORT] = args[ARG_CHILD_ERR_REPORT];
+
+ if (flags & G_SPAWN_WIN32_HIDDEN_CONSOLE)
+ handles_in_argv = TRUE;
@ -140,11 +128,11 @@ Index: glib/gspawn-win32.c
+
+ sprintf_file_descriptor (args[ARG_CHILD_ERR_REPORT],
+ child_err_report_pipe[1], handles_in_argv);
new_argv[ARG_CHILD_ERR_REPORT] = args[ARG_CHILD_ERR_REPORT];
if (flags & G_SPAWN_FILE_AND_ARGV_ZERO)
@@ -593,7 +664,7 @@ do_spawn_with_pipes (gint
/* Make the read end of the child error report pipe
* noninherited. Otherwise it will needlessly be inherited by the
@@ -638,7 +710,7 @@ do_spawn_with_pipes (gint
if (standard_input)
{
- _g_sprintf (args[ARG_STDIN], "%d", stdin_pipe[0]);
@ -152,7 +140,7 @@ Index: glib/gspawn-win32.c
new_argv[ARG_STDIN] = args[ARG_STDIN];
}
else if (flags & G_SPAWN_CHILD_INHERITS_STDIN)
@@ -609,7 +680,7 @@ do_spawn_with_pipes (gint
@@ -654,7 +726,7 @@ do_spawn_with_pipes (gint
if (standard_output)
{
@ -161,7 +149,7 @@ Index: glib/gspawn-win32.c
new_argv[ARG_STDOUT] = args[ARG_STDOUT];
}
else if (flags & G_SPAWN_STDOUT_TO_DEV_NULL)
@@ -623,7 +694,7 @@ do_spawn_with_pipes (gint
@@ -668,7 +740,7 @@ do_spawn_with_pipes (gint
if (standard_error)
{
@ -170,9 +158,9 @@ Index: glib/gspawn-win32.c
new_argv[ARG_STDERR] = args[ARG_STDERR];
}
else if (flags & G_SPAWN_STDERR_TO_DEV_NULL)
@@ -704,7 +775,13 @@ do_spawn_with_pipes (gint
if (child_setup)
(* child_setup) (user_data);
@@ -754,7 +826,13 @@ do_spawn_with_pipes (gint
whelper = g_utf8_to_utf16 (helper_process, -1, NULL, NULL, NULL);
g_free (helper_process);
- if (wenvp != NULL)
+ if (flags & G_SPAWN_WIN32_HIDDEN_CONSOLE)
@ -182,10 +170,10 @@ Index: glib/gspawn-win32.c
+ error_set = TRUE;
+ }
+ else if (wenvp != NULL)
/* Let's hope envp hasn't mucked with PATH so that
* gspawn-win32-helper.exe isn't found.
*/
@@ -732,11 +809,12 @@ do_spawn_with_pipes (gint
rc = _wspawnvpe (P_NOWAIT, whelper, (const wchar_t **) wargv, (const wchar_t **) wenvp);
else
rc = _wspawnvp (P_NOWAIT, whelper, (const wchar_t **) wargv);
@@ -781,11 +859,12 @@ do_spawn_with_pipes (gint
g_free (new_argv);
/* Check if gspawn-win32-helper couldn't be run */
@ -202,11 +190,25 @@ Index: glib/gspawn-win32.c
goto cleanup_and_fail;
}
Index: glib/gspawn.h
===================================================================
--- glib/gspawn.h (revision 6898)
+++ glib/gspawn.h (working copy)
@@ -71,6 +71,9 @@ typedef enum
G_SPAWN_STDERR_TO_DEV_NULL = 1 << 4,
G_SPAWN_CHILD_INHERITS_STDIN = 1 << 5,
G_SPAWN_FILE_AND_ARGV_ZERO = 1 << 6
+#ifdef G_OS_WIN32
+ , G_SPAWN_WIN32_HIDDEN_CONSOLE = 1 << 7
+#endif
} GSpawnFlags;
GQuark g_spawn_error_quark (void);
Index: glib/gspawn-win32-helper.c
===================================================================
--- glib/gspawn-win32-helper.c (revision 6301)
--- glib/gspawn-win32-helper.c (revision 6898)
+++ glib/gspawn-win32-helper.c (working copy)
@@ -145,6 +145,16 @@ protect_wargv (wchar_t **wargv,
@@ -147,6 +147,16 @@ protect_wargv (wchar_t **wargv,
return argc;
}
@ -223,15 +225,15 @@ Index: glib/gspawn-win32-helper.c
int _stdcall
WinMain (struct HINSTANCE__ *hInstance,
struct HINSTANCE__ *hPrevInstance,
@@ -163,6 +173,7 @@ WinMain (struct HINSTANCE__ *hInstance,
@@ -166,6 +176,7 @@ WinMain (struct HINSTANCE__ *hInstance,
wchar_t **new_wargv;
int argc;
wchar_t **wargv, **wenvp;
+ gboolean handles_in_argv;
_startupinfo si = { 0 };
char c;
g_assert (__argc >= ARG_COUNT);
@@ -176,10 +187,17 @@ WinMain (struct HINSTANCE__ *hInstance,
@@ -180,10 +191,17 @@ WinMain (struct HINSTANCE__ *hInstance,
*/
g_assert (argc == __argc);
@ -251,16 +253,16 @@ Index: glib/gspawn-win32-helper.c
/* Hack to implement G_SPAWN_FILE_AND_ARGV_ZERO. If
* argv[ARG_CHILD_ERR_REPORT] is suffixed with a '#' it means we get
@@ -188,7 +206,7 @@ WinMain (struct HINSTANCE__ *hInstance,
if (__argv[ARG_CHILD_ERR_REPORT][strlen (__argv[ARG_CHILD_ERR_REPORT]) - 1] == '#')
argv_zero_offset++;
@@ -200,7 +218,7 @@ WinMain (struct HINSTANCE__ *hInstance,
*/
helper_sync_fd = atoi (__argv[ARG_HELPER_SYNC]);
- /* argv[ARG_STDIN..ARG_STDERR] are the file descriptor numbers that
+ /* argv[ARG_STDIN..ARG_STDERR] are the pipe handles that
* should be dup2'd to 0, 1 and 2. '-' if the corresponding fd
* should be left alone, and 'z' if it should be connected to the
* bit bucket NUL:.
@@ -206,7 +224,9 @@ WinMain (struct HINSTANCE__ *hInstance,
@@ -218,7 +236,9 @@ WinMain (struct HINSTANCE__ *hInstance,
}
else
{
@ -271,7 +273,7 @@ Index: glib/gspawn-win32-helper.c
if (fd != 0)
{
dup2 (fd, 0);
@@ -227,7 +247,9 @@ WinMain (struct HINSTANCE__ *hInstance,
@@ -239,7 +259,9 @@ WinMain (struct HINSTANCE__ *hInstance,
}
else
{
@ -282,7 +284,7 @@ Index: glib/gspawn-win32-helper.c
if (fd != 1)
{
dup2 (fd, 1);
@@ -248,7 +270,9 @@ WinMain (struct HINSTANCE__ *hInstance,
@@ -260,7 +282,9 @@ WinMain (struct HINSTANCE__ *hInstance,
}
else
{