+2005-09-07 Tor Lillqvist <tml@novell.com>
+
+ * glib/Makefile.am: Create also a console version of the
+ gspawn-win32-helper program, gspawn-win32-helper-console.exe.
+ It's otherwise identical to gspawn-win32-helper.exe, except marked
+ as a console application (linked without the -mwindows option).
+
+ * glib/gspawn-win32.c (do_spawn_directly, do_spawn_with_pipes):
+ Drop the dont_wait parameter. Its truth value correlated 100% with
+ the NULLness of the exit_status parameter anyway, so it's enough
+ to check whether exit_status is NULL. Invert the sense of the
+ dont_return_handle parameter and rename it to do_return_handle, to
+ make the code easier to read by avoiding double negations.
+
+ (g_spawn_sync_utf8, g_spawn_async_with_pipes_utf8): Modify calls
+ to do_spawn_with_pipes() accordingly.
+
+ (do_spawn_with_pipes): If we have a console, use the console
+ version of the helper program, otherwise use the GUI one. This
+ avoids extra console windows opening up in some situations. (In
+ case a console application uses the GUI gspawn-win32-helper.exe to
+ spawn another console application we would get a separate console
+ for the spawned console application).
+
+ * glib-zip.in: Distribute also gspawn-win32-helper-console.exe.
+
2005-09-05 Matthias Clasen <mclasen@redhat.com>
* glib/gmappedfile.c (g_mapped_file_new): Report an error
+2005-09-07 Tor Lillqvist <tml@novell.com>
+
+ * glib/Makefile.am: Create also a console version of the
+ gspawn-win32-helper program, gspawn-win32-helper-console.exe.
+ It's otherwise identical to gspawn-win32-helper.exe, except marked
+ as a console application (linked without the -mwindows option).
+
+ * glib/gspawn-win32.c (do_spawn_directly, do_spawn_with_pipes):
+ Drop the dont_wait parameter. Its truth value correlated 100% with
+ the NULLness of the exit_status parameter anyway, so it's enough
+ to check whether exit_status is NULL. Invert the sense of the
+ dont_return_handle parameter and rename it to do_return_handle, to
+ make the code easier to read by avoiding double negations.
+
+ (g_spawn_sync_utf8, g_spawn_async_with_pipes_utf8): Modify calls
+ to do_spawn_with_pipes() accordingly.
+
+ (do_spawn_with_pipes): If we have a console, use the console
+ version of the helper program, otherwise use the GUI one. This
+ avoids extra console windows opening up in some situations. (In
+ case a console application uses the GUI gspawn-win32-helper.exe to
+ spawn another console application we would get a separate console
+ for the spawned console application).
+
+ * glib-zip.in: Distribute also gspawn-win32-helper-console.exe.
+
2005-09-05 Matthias Clasen <mclasen@redhat.com>
* glib/gmappedfile.c (g_mapped_file_new): Report an error
+2005-09-07 Tor Lillqvist <tml@novell.com>
+
+ * glib/Makefile.am: Create also a console version of the
+ gspawn-win32-helper program, gspawn-win32-helper-console.exe.
+ It's otherwise identical to gspawn-win32-helper.exe, except marked
+ as a console application (linked without the -mwindows option).
+
+ * glib/gspawn-win32.c (do_spawn_directly, do_spawn_with_pipes):
+ Drop the dont_wait parameter. Its truth value correlated 100% with
+ the NULLness of the exit_status parameter anyway, so it's enough
+ to check whether exit_status is NULL. Invert the sense of the
+ dont_return_handle parameter and rename it to do_return_handle, to
+ make the code easier to read by avoiding double negations.
+
+ (g_spawn_sync_utf8, g_spawn_async_with_pipes_utf8): Modify calls
+ to do_spawn_with_pipes() accordingly.
+
+ (do_spawn_with_pipes): If we have a console, use the console
+ version of the helper program, otherwise use the GUI one. This
+ avoids extra console windows opening up in some situations. (In
+ case a console application uses the GUI gspawn-win32-helper.exe to
+ spawn another console application we would get a separate console
+ for the spawned console application).
+
+ * glib-zip.in: Distribute also gspawn-win32-helper-console.exe.
+
2005-09-05 Matthias Clasen <mclasen@redhat.com>
* glib/gmappedfile.c (g_mapped_file_new): Report an error
}
static gboolean
-do_spawn_directly (gboolean dont_wait,
- gboolean dont_return_handle,
+do_spawn_directly (gint *exit_status,
+ gboolean do_return_handle,
GSpawnFlags flags,
gchar **argv,
char **envp,
GSpawnChildSetupFunc child_setup,
gpointer user_data,
GPid *child_handle,
- gint *exit_status,
GError **error)
{
- int mode = dont_wait ? P_NOWAIT : P_WAIT;
+ const int mode = (exit_status == NULL) ? P_NOWAIT : P_WAIT;
char **new_argv;
int rc = -1;
int saved_errno;
return FALSE;
}
- if (dont_wait)
+ if (exit_status == NULL)
{
- if (child_handle && !dont_return_handle)
+ if (child_handle && do_return_handle)
*child_handle = (GPid) rc;
else
{
*child_handle = 0;
}
}
- else if (exit_status)
+ else
*exit_status = rc;
return TRUE;
}
static gboolean
-do_spawn_with_pipes (gboolean dont_wait,
- gboolean dont_return_handle,
+do_spawn_with_pipes (gint *exit_status,
+ gboolean do_return_handle,
const gchar *working_directory,
gchar **argv,
char **envp,
gint *standard_input,
gint *standard_output,
gint *standard_error,
- gint *exit_status,
gint *err_report,
GError **error)
{
static gboolean warned_about_child_setup = FALSE;
GError *conv_error = NULL;
gint conv_error_index;
+ gchar *helper_process;
+ CONSOLE_CURSOR_INFO cursor_info;
SETUP_DEBUG();
{
/* We can do without the helper process */
gboolean retval =
- do_spawn_directly (dont_wait, dont_return_handle, flags,
+ do_spawn_directly (exit_status, do_return_handle, flags,
argv, envp, protected_argv,
child_setup, user_data, child_handle,
- exit_status, error);
+ error);
g_strfreev (protected_argv);
return retval;
}
goto cleanup_and_fail;
new_argv = g_new (char *, argc + 1 + ARG_COUNT);
- new_argv[0] = HELPER_PROCESS;
+ if (GetConsoleCursorInfo (GetStdHandle (STD_OUTPUT_HANDLE), &cursor_info))
+ 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]);
new_argv[ARG_CHILD_ERR_REPORT] = args[ARG_CHILD_ERR_REPORT];
else
new_argv[ARG_USE_PATH] = "-";
- if (dont_wait)
+ if (exit_status == NULL)
new_argv[ARG_WAIT] = "-";
else
new_argv[ARG_WAIT] = "w";
if (debug)
{
- g_print ("calling " HELPER_PROCESS " with argv:\n");
+ g_print ("calling %s with argv:\n", helper_process);
for (i = 0; i < argc + 1 + ARG_COUNT; i++)
g_print ("argv[%d]: %s\n", i, (new_argv[i] ? new_argv[i] : "NULL"));
}
if (G_WIN32_HAVE_WIDECHAR_API ())
{
- wchar_t *whelper = g_utf8_to_utf16 (HELPER_PROCESS, -1, NULL, NULL, NULL);
+ wchar_t *whelper = g_utf8_to_utf16 (helper_process, -1, NULL, NULL, NULL);
wchar_t **wargv, **wenvp;
if (!utf8_charv_to_wcharv (new_argv, &wargv, &conv_error_index, &conv_error))
(* child_setup) (user_data);
if (cpenvp != NULL)
- rc = spawnvpe (P_NOWAIT, HELPER_PROCESS, (const char **) cpargv, (const char **) cpenvp);
+ rc = spawnvpe (P_NOWAIT, helper_process, (const char **) cpargv, (const char **) cpenvp);
else
- rc = spawnvp (P_NOWAIT, HELPER_PROCESS, (const char **) cpargv);
+ rc = spawnvp (P_NOWAIT, helper_process, (const char **) cpargv);
saved_errno = errno;
goto cleanup_and_fail;
}
- if (!dont_wait)
+ if (exit_status != NULL)
{
/* Synchronous case. Pass helper's report pipe back to caller,
* which takes care of reading it after the grandchild has
switch (helper_report[0])
{
case CHILD_NO_ERROR:
- if (child_handle && dont_wait && !dont_return_handle)
+ if (child_handle && do_return_handle)
{
/* rc is our HANDLE for gspawn-win32-helper. It has
* told us the HANDLE of its child. Duplicate that into
}
else if (child_handle)
*child_handle = 0;
- if (exit_status)
- *exit_status = helper_report[1];
break;
default:
if (standard_error)
*standard_error = NULL;
- if (!do_spawn_with_pipes (FALSE,
- TRUE,
+ if (!do_spawn_with_pipes (&status,
+ FALSE,
working_directory,
argv,
envp,
NULL,
standard_output ? &outpipe : NULL,
standard_error ? &errpipe : NULL,
- &status,
&reportpipe,
error))
return FALSE;
g_return_val_if_fail (standard_input == NULL ||
!(flags & G_SPAWN_CHILD_INHERITS_STDIN), FALSE);
- return do_spawn_with_pipes (TRUE,
- !(flags & G_SPAWN_DO_NOT_REAP_CHILD),
+ return do_spawn_with_pipes (NULL,
+ (flags & G_SPAWN_DO_NOT_REAP_CHILD),
working_directory,
argv,
envp,
standard_output,
standard_error,
NULL,
- NULL,
error);
}