2002-11-18 Tor Lillqvist <tml@iki.fi>
+ * glib/gspawn-win32.c (do_spawn_with_pipes): Do handle
+ G_SPAWN_DO_NOT_REAP_CHILD after all, similarily as on Unix. If the
+ flag is not set, don't call DuplicateHandle() on the handle
+ returned by the helper process, and set the "child pid" returned
+ to the called to zero. Close the handle to the helper process in
+ all cases.
+
+ * glib/gspawn.c (g_spawn_async_with_pipes): Document Windows
+ behaviour of G_SPAWN_DO_NOT_REAP_CHILD.
+
+2002-11-18 Tor Lillqvist <tml@iki.fi>
+
[Win32] Fix the asynchronous g_spawn* to return the process handle
of the started program properly. (Note: not the process id. The
spawn*() functions in the C runtime return the created process's
2002-11-18 Tor Lillqvist <tml@iki.fi>
+ * glib/gspawn-win32.c (do_spawn_with_pipes): Do handle
+ G_SPAWN_DO_NOT_REAP_CHILD after all, similarily as on Unix. If the
+ flag is not set, don't call DuplicateHandle() on the handle
+ returned by the helper process, and set the "child pid" returned
+ to the called to zero. Close the handle to the helper process in
+ all cases.
+
+ * glib/gspawn.c (g_spawn_async_with_pipes): Document Windows
+ behaviour of G_SPAWN_DO_NOT_REAP_CHILD.
+
+2002-11-18 Tor Lillqvist <tml@iki.fi>
+
[Win32] Fix the asynchronous g_spawn* to return the process handle
of the started program properly. (Note: not the process id. The
spawn*() functions in the C runtime return the created process's
2002-11-18 Tor Lillqvist <tml@iki.fi>
+ * glib/gspawn-win32.c (do_spawn_with_pipes): Do handle
+ G_SPAWN_DO_NOT_REAP_CHILD after all, similarily as on Unix. If the
+ flag is not set, don't call DuplicateHandle() on the handle
+ returned by the helper process, and set the "child pid" returned
+ to the called to zero. Close the handle to the helper process in
+ all cases.
+
+ * glib/gspawn.c (g_spawn_async_with_pipes): Document Windows
+ behaviour of G_SPAWN_DO_NOT_REAP_CHILD.
+
+2002-11-18 Tor Lillqvist <tml@iki.fi>
+
[Win32] Fix the asynchronous g_spawn* to return the process handle
of the started program properly. (Note: not the process id. The
spawn*() functions in the C runtime return the created process's
2002-11-18 Tor Lillqvist <tml@iki.fi>
+ * glib/gspawn-win32.c (do_spawn_with_pipes): Do handle
+ G_SPAWN_DO_NOT_REAP_CHILD after all, similarily as on Unix. If the
+ flag is not set, don't call DuplicateHandle() on the handle
+ returned by the helper process, and set the "child pid" returned
+ to the called to zero. Close the handle to the helper process in
+ all cases.
+
+ * glib/gspawn.c (g_spawn_async_with_pipes): Document Windows
+ behaviour of G_SPAWN_DO_NOT_REAP_CHILD.
+
+2002-11-18 Tor Lillqvist <tml@iki.fi>
+
[Win32] Fix the asynchronous g_spawn* to return the process handle
of the started program properly. (Note: not the process id. The
spawn*() functions in the C runtime return the created process's
2002-11-18 Tor Lillqvist <tml@iki.fi>
+ * glib/gspawn-win32.c (do_spawn_with_pipes): Do handle
+ G_SPAWN_DO_NOT_REAP_CHILD after all, similarily as on Unix. If the
+ flag is not set, don't call DuplicateHandle() on the handle
+ returned by the helper process, and set the "child pid" returned
+ to the called to zero. Close the handle to the helper process in
+ all cases.
+
+ * glib/gspawn.c (g_spawn_async_with_pipes): Document Windows
+ behaviour of G_SPAWN_DO_NOT_REAP_CHILD.
+
+2002-11-18 Tor Lillqvist <tml@iki.fi>
+
[Win32] Fix the asynchronous g_spawn* to return the process handle
of the started program properly. (Note: not the process id. The
spawn*() functions in the C runtime return the created process's
2002-11-18 Tor Lillqvist <tml@iki.fi>
+ * glib/gspawn-win32.c (do_spawn_with_pipes): Do handle
+ G_SPAWN_DO_NOT_REAP_CHILD after all, similarily as on Unix. If the
+ flag is not set, don't call DuplicateHandle() on the handle
+ returned by the helper process, and set the "child pid" returned
+ to the called to zero. Close the handle to the helper process in
+ all cases.
+
+ * glib/gspawn.c (g_spawn_async_with_pipes): Document Windows
+ behaviour of G_SPAWN_DO_NOT_REAP_CHILD.
+
+2002-11-18 Tor Lillqvist <tml@iki.fi>
+
[Win32] Fix the asynchronous g_spawn* to return the process handle
of the started program properly. (Note: not the process id. The
spawn*() functions in the C runtime return the created process's
2002-11-18 Tor Lillqvist <tml@iki.fi>
+ * glib/gspawn-win32.c (do_spawn_with_pipes): Do handle
+ G_SPAWN_DO_NOT_REAP_CHILD after all, similarily as on Unix. If the
+ flag is not set, don't call DuplicateHandle() on the handle
+ returned by the helper process, and set the "child pid" returned
+ to the called to zero. Close the handle to the helper process in
+ all cases.
+
+ * glib/gspawn.c (g_spawn_async_with_pipes): Document Windows
+ behaviour of G_SPAWN_DO_NOT_REAP_CHILD.
+
+2002-11-18 Tor Lillqvist <tml@iki.fi>
+
[Win32] Fix the asynchronous g_spawn* to return the process handle
of the started program properly. (Note: not the process id. The
spawn*() functions in the C runtime return the created process's
static gboolean make_pipe (gint p[2],
GError **error);
static gboolean do_spawn_with_pipes (gboolean dont_wait,
+ gboolean dont_return_handle,
const gchar *working_directory,
gchar **argv,
gchar **envp,
*standard_error = NULL;
if (!do_spawn_with_pipes (FALSE,
+ TRUE,
working_directory,
argv,
envp,
!(flags & G_SPAWN_CHILD_INHERITS_STDIN), FALSE);
return do_spawn_with_pipes (TRUE,
+ !(flags & G_SPAWN_DO_NOT_REAP_CHILD),
working_directory,
argv,
envp,
static gboolean
do_spawn_with_pipes (gboolean dont_wait,
+ gboolean dont_return_handle,
const gchar *working_directory,
gchar **argv,
gchar **envp,
switch (buf[0])
{
case CHILD_NO_ERROR:
- if (child_pid && dont_wait)
+ if (child_pid && dont_wait && !dont_return_handle)
{
/* helper is our HANDLE for gspawn-win32-helper. It has
* told us the HANDLE of its child. Duplicate that into
*standard_error = stderr_pipe[0];
if (exit_status)
*exit_status = buf[1];
+ CloseHandle ((HANDLE) helper);
return TRUE;
* parent's environment.
*
* @flags should be the bitwise OR of any flags you want to affect the
- * function's behavior. The %G_SPAWN_DO_NOT_REAP_CHILD means that the
- * child will not be automatically reaped; you must call
- * <function>waitpid()</function> or handle %SIGCHLD yourself, or the
- * child will become a zombie.
+ * function's behavior. On Unix, the %G_SPAWN_DO_NOT_REAP_CHILD means
+ * that the child will not be automatically reaped; you must call
+ * <function>waitpid()</function> or handle %SIGCHLD yourself, or the
+ * child will become a zombie. On Windows, the flag means that a
+ * handle to the child will be returned @child_pid. You must call
+ * <function>CloseHandle()</function> on it eventually (or exit the
+ * process), or the child processs will continue to take up some table
+ * space even after its death. Quite similar to zombies on Unix,
+ * actually.
+ *
* %G_SPAWN_LEAVE_DESCRIPTORS_OPEN means that the parent's open file
* descriptors will be inherited by the child; otherwise all
* descriptors except stdin/stdout/stderr will be closed before
* process. You should carefully consider what you do in @child_setup
* if you intend your software to be portable to Windows.
*
- * If non-%NULL, @child_pid will be filled with the child's process
- * ID. You can use the process ID to send signals to the child, or
- * to <function>waitpid()</function> if you specified the
- * %G_SPAWN_DO_NOT_REAP_CHILD flag.
+ * If non-%NULL, @child_pid will on Unix be filled with the child's
+ * process ID. You can use the process ID to send signals to the
+ * child, or to <function>waitpid()</function> if you specified the
+ * %G_SPAWN_DO_NOT_REAP_CHILD flag. On Windows, @child_pid will be
+ * filled with a handle to the child process only if you specified the
+ * %G_SPAWN_DO_NOT_REAP_CHILD flag. You can then access the child
+ * process using the Win32 API, for example wait for its termination
+ * with the <function>WaitFor*()</function> functions, or examine its
+ * exit code with <function>GetExitCodeProcess()</function>. You
+ * should close the handle with <function>CloseHandle()</function>
+ * when you no longer need it.
*
* If non-%NULL, the @standard_input, @standard_output, @standard_error
* locations will be filled with file descriptors for writing to the child's