+Mon Mar 1 15:39:57 2004 Owen Taylor <otaylor@redhat.com>
+
+ Patch from J. Ali Harlow
+
+ * configure.in: Use void * not HANDLE for GPid on win32.
+
+ * glib/gspawn.[ch] glib/gspawn-win32.[ch] glib/glib.def:
+ Add g_spawn_close_pid().
+
+ * glib/gspawn.[ch]: Make g_spawn functions take
+ GPid * instead if int * (GPid == int on unix, will
+ produce compile warnings until fixed on Win32.)
+
+ * tests/child-test.c: Make the test a little more
+ inappropriately verbose.
+
+ * glib/gmain.c: Add some documentation warnings about
+ not closing @pid while the source is active.
+
Mon Mar 1 20:32:06 2004 Tim Janik <timj@gtk.org>
* autogen.sh:
+Mon Mar 1 15:39:57 2004 Owen Taylor <otaylor@redhat.com>
+
+ Patch from J. Ali Harlow
+
+ * configure.in: Use void * not HANDLE for GPid on win32.
+
+ * glib/gspawn.[ch] glib/gspawn-win32.[ch] glib/glib.def:
+ Add g_spawn_close_pid().
+
+ * glib/gspawn.[ch]: Make g_spawn functions take
+ GPid * instead if int * (GPid == int on unix, will
+ produce compile warnings until fixed on Win32.)
+
+ * tests/child-test.c: Make the test a little more
+ inappropriately verbose.
+
+ * glib/gmain.c: Add some documentation warnings about
+ not closing @pid while the source is active.
+
Mon Mar 1 20:32:06 2004 Tim Janik <timj@gtk.org>
* autogen.sh:
+Mon Mar 1 15:39:57 2004 Owen Taylor <otaylor@redhat.com>
+
+ Patch from J. Ali Harlow
+
+ * configure.in: Use void * not HANDLE for GPid on win32.
+
+ * glib/gspawn.[ch] glib/gspawn-win32.[ch] glib/glib.def:
+ Add g_spawn_close_pid().
+
+ * glib/gspawn.[ch]: Make g_spawn functions take
+ GPid * instead if int * (GPid == int on unix, will
+ produce compile warnings until fixed on Win32.)
+
+ * tests/child-test.c: Make the test a little more
+ inappropriately verbose.
+
+ * glib/gmain.c: Add some documentation warnings about
+ not closing @pid while the source is active.
+
Mon Mar 1 20:32:06 2004 Tim Janik <timj@gtk.org>
* autogen.sh:
+Mon Mar 1 15:39:57 2004 Owen Taylor <otaylor@redhat.com>
+
+ Patch from J. Ali Harlow
+
+ * configure.in: Use void * not HANDLE for GPid on win32.
+
+ * glib/gspawn.[ch] glib/gspawn-win32.[ch] glib/glib.def:
+ Add g_spawn_close_pid().
+
+ * glib/gspawn.[ch]: Make g_spawn functions take
+ GPid * instead if int * (GPid == int on unix, will
+ produce compile warnings until fixed on Win32.)
+
+ * tests/child-test.c: Make the test a little more
+ inappropriately verbose.
+
+ * glib/gmain.c: Add some documentation warnings about
+ not closing @pid while the source is active.
+
Mon Mar 1 20:32:06 2004 Tim Janik <timj@gtk.org>
* autogen.sh:
+Mon Mar 1 15:39:57 2004 Owen Taylor <otaylor@redhat.com>
+
+ Patch from J. Ali Harlow
+
+ * configure.in: Use void * not HANDLE for GPid on win32.
+
+ * glib/gspawn.[ch] glib/gspawn-win32.[ch] glib/glib.def:
+ Add g_spawn_close_pid().
+
+ * glib/gspawn.[ch]: Make g_spawn functions take
+ GPid * instead if int * (GPid == int on unix, will
+ produce compile warnings until fixed on Win32.)
+
+ * tests/child-test.c: Make the test a little more
+ inappropriately verbose.
+
+ * glib/gmain.c: Add some documentation warnings about
+ not closing @pid while the source is active.
+
Mon Mar 1 20:32:06 2004 Tim Janik <timj@gtk.org>
* autogen.sh:
+Mon Mar 1 15:39:57 2004 Owen Taylor <otaylor@redhat.com>
+
+ Patch from J. Ali Harlow
+
+ * configure.in: Use void * not HANDLE for GPid on win32.
+
+ * glib/gspawn.[ch] glib/gspawn-win32.[ch] glib/glib.def:
+ Add g_spawn_close_pid().
+
+ * glib/gspawn.[ch]: Make g_spawn functions take
+ GPid * instead if int * (GPid == int on unix, will
+ produce compile warnings until fixed on Win32.)
+
+ * tests/child-test.c: Make the test a little more
+ inappropriately verbose.
+
+ * glib/gmain.c: Add some documentation warnings about
+ not closing @pid while the source is active.
+
Mon Mar 1 20:32:06 2004 Tim Janik <timj@gtk.org>
* autogen.sh:
GOBJECT_DEF=gobject.def
GTHREAD_DEF=gthread.def
TESTGMODULE_EXP=testgmodule.exp
- glib_pid_type=HANDLE
+ glib_pid_type='void *'
;;
*)
glib_native_win32=no
g_spawn_sync
g_spawn_command_line_async
g_spawn_command_line_sync
+g_spawn_close_pid
<SUBSECTION Private>
g_spawn_error_quark
</SECTION>
g_spaced_primes_closest
g_spawn_async
g_spawn_async_with_pipes
+ g_spawn_close_pid
g_spawn_command_line_async
g_spawn_command_line_sync
g_spawn_error_quark
* and must be added to one with g_source_attach() before it will be
* executed.
*
+ * Note that on platforms where #GPid must be explicitely closed
+ * (see g_spawn_close_pid()) @pid must not be closed while the
+ * source is still active. Typically, you will want to call
+ * g_spawn_close_pid() in the callback function for the source.
+ *
* Return value: the newly-created child watch source
*
* Since: 2.4
* Sets a function to be called when the child indicated by @pid exits, at a
* default priority, #G_PRIORITY_DEFAULT.
*
+ * Note that on platforms where #GPid must be explicitely closed
+ * (see g_spawn_close_pid()) @pid must not be closed while the
+ * source is still active. Typically, you will want to call
+ * g_spawn_close_pid() in the callback function for the source.
+ *
* Return value: the id of event source.
*
* Since: 2.4
* Sets a function to be called when the child indicated by @pid exits, at a
* default priority, #G_PRIORITY_DEFAULT.
*
+ * Note that on platforms where #GPid must be explicitely closed
+ * (see g_spawn_close_pid()) @pid must not be closed while the
+ * source is still active. Typically, you will want to call
+ * g_spawn_close_pid() in the callback function for the source.
+ *
* Return value: the id of event source.
*
* Since: 2.4
gboolean file_and_argv_zero,
GSpawnChildSetupFunc child_setup,
gpointer user_data,
- gint *child_handle,
+ GPid *child_handle,
gint *standard_input,
gint *standard_output,
gint *standard_error,
GSpawnFlags flags,
GSpawnChildSetupFunc child_setup,
gpointer user_data,
- gint *child_handle,
+ GPid *child_handle,
GError **error)
{
g_return_val_if_fail (argv != NULL, FALSE);
{
gint outpipe = -1;
gint errpipe = -1;
- gint pid;
+ GPid pid;
GIOChannel *outchannel = NULL;
GIOChannel *errchannel = NULL;
GPollFD outfd, errfd;
if (errpipe >= 0)
close_and_invalidate (&errpipe);
+ g_spawn_close_pid(pid);
+
if (failed)
{
if (outstr)
GSpawnFlags flags,
GSpawnChildSetupFunc child_setup,
gpointer user_data,
- gint *child_handle,
+ GPid *child_handle,
gint *standard_input,
gint *standard_output,
gint *standard_error,
gboolean file_and_argv_zero,
GSpawnChildSetupFunc child_setup,
gpointer user_data,
- gint *child_handle,
+ GPid *child_handle,
gint *standard_input,
gint *standard_output,
gint *standard_error,
else
return TRUE;
}
-
#endif /* !GSPAWN_HELPER */
+
+void
+g_spawn_close_pid (GPid pid)
+{
+ CloseHandle (pid);
+}
gboolean file_and_argv_zero,
GSpawnChildSetupFunc child_setup,
gpointer user_data,
- gint *child_pid,
+ GPid *child_pid,
gint *standard_input,
gint *standard_output,
gint *standard_error,
GSpawnFlags flags,
GSpawnChildSetupFunc child_setup,
gpointer user_data,
- gint *child_pid,
+ GPid *child_pid,
GError **error)
{
g_return_val_if_fail (argv != NULL, FALSE);
{
gint outpipe = -1;
gint errpipe = -1;
- gint pid;
+ GPid pid;
fd_set fds;
gint ret;
GString *outstr = NULL;
*
* If an error occurs, @child_pid, @standard_input, @standard_output,
* and @standard_error will not be filled with valid values.
+ *
+ * If @child_pid is not %NULL and an error does not occur then the returned
+ * pid must be closed using g_spawn_close_pid().
*
* Return value: %TRUE on success, %FALSE if an error was set
**/
GSpawnFlags flags,
GSpawnChildSetupFunc child_setup,
gpointer user_data,
- gint *child_pid,
+ GPid *child_pid,
gint *standard_input,
gint *standard_output,
gint *standard_error,
gboolean file_and_argv_zero,
GSpawnChildSetupFunc child_setup,
gpointer user_data,
- gint *child_pid,
+ GPid *child_pid,
gint *standard_input,
gint *standard_output,
gint *standard_error,
GError **error)
{
- gint pid = -1;
+ GPid pid = -1;
gint stdin_pipe[2] = { -1, -1 };
gint stdout_pipe[2] = { -1, -1 };
gint stderr_pipe[2] = { -1, -1 };
* is to exit, so we can waitpid() it immediately.
* Then the grandchild will not become a zombie.
*/
- gint grandchild_pid;
+ GPid grandchild_pid;
grandchild_pid = fork ();
/* Return the error from the last attempt (probably ENOENT). */
return -1;
}
+
+/**
+ * g_spawn_close_pid:
+ * @pid: The process identifier to close
+ *
+ * On some platforms, notably WIN32, the #GPid type represents a resource
+ * which must be closed to prevent resource leaking. g_spawn_close_pid()
+ * is provided for this purpose. It should be used on all platforms, even
+ * though it doesn't do anything under UNIX.
+ **/
+void
+g_spawn_close_pid (GPid pid)
+{
+}
GSpawnFlags flags,
GSpawnChildSetupFunc child_setup,
gpointer user_data,
- gint *child_pid,
+ GPid *child_pid,
GError **error);
GSpawnFlags flags,
GSpawnChildSetupFunc child_setup,
gpointer user_data,
- gint *child_pid,
+ GPid *child_pid,
gint *standard_input,
gint *standard_output,
gint *standard_error,
gboolean g_spawn_command_line_async (const gchar *command_line,
GError **error);
+void g_spawn_close_pid (GPid pid);
+
G_END_DECLS
gboolean
child_watch_callback (GPid pid, gint status, gpointer data)
{
+ gint ttl = GPOINTER_TO_INT (data);
+
#ifndef G_OS_WIN32
- g_print ("child %d exited, status %d\n", pid, status);
+ g_print ("child %d (ttl %d) exited, status %d\n", pid, ttl, status);
#else
- g_print ("child %p exited, status %d\n", pid, status);
-
- CloseHandle(pid);
+ g_print ("child %p (ttl %d) exited, status %d\n", pid, ttl, status);
#endif
if (--alive == 0)
pid = get_a_child (ttl);
source = g_child_watch_source_new (pid);
- g_source_set_callback (source, (GSourceFunc) child_watch_callback, NULL, NULL);
+ g_source_set_callback (source, (GSourceFunc) child_watch_callback, data, NULL);
g_source_attach (source, g_main_loop_get_context (new_main_loop));
g_source_unref (source);
#ifdef G_OS_WIN32
- g_print ("whee! created pid: %p\n", pid);
+ g_print ("whee! created pid: %p (ttl %d)\n", pid, ttl);
+ CloseHandle(pid);
#else
- g_print ("whee! created pid: %d\n", pid);
+ g_print ("whee! created pid: %d (ttl %d)\n", pid, ttl);
#endif
g_main_loop_run (new_main_loop);