mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-15 06:47:14 +01:00
Patch from J. Ali Harlow
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.
This commit is contained in:
parent
6c6e41510a
commit
38cbfaeb7a
19
ChangeLog
19
ChangeLog
@ -1,3 +1,22 @@
|
|||||||
|
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>
|
Mon Mar 1 20:32:06 2004 Tim Janik <timj@gtk.org>
|
||||||
|
|
||||||
* autogen.sh:
|
* autogen.sh:
|
||||||
|
@ -1,3 +1,22 @@
|
|||||||
|
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>
|
Mon Mar 1 20:32:06 2004 Tim Janik <timj@gtk.org>
|
||||||
|
|
||||||
* autogen.sh:
|
* autogen.sh:
|
||||||
|
@ -1,3 +1,22 @@
|
|||||||
|
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>
|
Mon Mar 1 20:32:06 2004 Tim Janik <timj@gtk.org>
|
||||||
|
|
||||||
* autogen.sh:
|
* autogen.sh:
|
||||||
|
@ -1,3 +1,22 @@
|
|||||||
|
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>
|
Mon Mar 1 20:32:06 2004 Tim Janik <timj@gtk.org>
|
||||||
|
|
||||||
* autogen.sh:
|
* autogen.sh:
|
||||||
|
@ -1,3 +1,22 @@
|
|||||||
|
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>
|
Mon Mar 1 20:32:06 2004 Tim Janik <timj@gtk.org>
|
||||||
|
|
||||||
* autogen.sh:
|
* autogen.sh:
|
||||||
|
@ -1,3 +1,22 @@
|
|||||||
|
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>
|
Mon Mar 1 20:32:06 2004 Tim Janik <timj@gtk.org>
|
||||||
|
|
||||||
* autogen.sh:
|
* autogen.sh:
|
||||||
|
@ -131,7 +131,7 @@ case "$host" in
|
|||||||
GOBJECT_DEF=gobject.def
|
GOBJECT_DEF=gobject.def
|
||||||
GTHREAD_DEF=gthread.def
|
GTHREAD_DEF=gthread.def
|
||||||
TESTGMODULE_EXP=testgmodule.exp
|
TESTGMODULE_EXP=testgmodule.exp
|
||||||
glib_pid_type=HANDLE
|
glib_pid_type='void *'
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
glib_native_win32=no
|
glib_native_win32=no
|
||||||
|
@ -874,6 +874,7 @@ g_spawn_async
|
|||||||
g_spawn_sync
|
g_spawn_sync
|
||||||
g_spawn_command_line_async
|
g_spawn_command_line_async
|
||||||
g_spawn_command_line_sync
|
g_spawn_command_line_sync
|
||||||
|
g_spawn_close_pid
|
||||||
<SUBSECTION Private>
|
<SUBSECTION Private>
|
||||||
g_spawn_error_quark
|
g_spawn_error_quark
|
||||||
</SECTION>
|
</SECTION>
|
||||||
|
@ -579,6 +579,7 @@ EXPORTS
|
|||||||
g_spaced_primes_closest
|
g_spaced_primes_closest
|
||||||
g_spawn_async
|
g_spawn_async
|
||||||
g_spawn_async_with_pipes
|
g_spawn_async_with_pipes
|
||||||
|
g_spawn_close_pid
|
||||||
g_spawn_command_line_async
|
g_spawn_command_line_async
|
||||||
g_spawn_command_line_sync
|
g_spawn_command_line_sync
|
||||||
g_spawn_error_quark
|
g_spawn_error_quark
|
||||||
|
15
glib/gmain.c
15
glib/gmain.c
@ -3634,6 +3634,11 @@ g_child_watch_source_init (void)
|
|||||||
* and must be added to one with g_source_attach() before it will be
|
* and must be added to one with g_source_attach() before it will be
|
||||||
* executed.
|
* 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
|
* Return value: the newly-created child watch source
|
||||||
*
|
*
|
||||||
* Since: 2.4
|
* Since: 2.4
|
||||||
@ -3670,6 +3675,11 @@ g_child_watch_source_new (GPid pid)
|
|||||||
* Sets a function to be called when the child indicated by @pid exits, at a
|
* Sets a function to be called when the child indicated by @pid exits, at a
|
||||||
* default priority, #G_PRIORITY_DEFAULT.
|
* 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.
|
* Return value: the id of event source.
|
||||||
*
|
*
|
||||||
* Since: 2.4
|
* Since: 2.4
|
||||||
@ -3707,6 +3717,11 @@ g_child_watch_add_full (gint priority,
|
|||||||
* Sets a function to be called when the child indicated by @pid exits, at a
|
* Sets a function to be called when the child indicated by @pid exits, at a
|
||||||
* default priority, #G_PRIORITY_DEFAULT.
|
* 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.
|
* Return value: the id of event source.
|
||||||
*
|
*
|
||||||
* Since: 2.4
|
* Since: 2.4
|
||||||
|
@ -202,7 +202,7 @@ static gboolean do_spawn_with_pipes (gboolean dont_wait,
|
|||||||
gboolean file_and_argv_zero,
|
gboolean file_and_argv_zero,
|
||||||
GSpawnChildSetupFunc child_setup,
|
GSpawnChildSetupFunc child_setup,
|
||||||
gpointer user_data,
|
gpointer user_data,
|
||||||
gint *child_handle,
|
GPid *child_handle,
|
||||||
gint *standard_input,
|
gint *standard_input,
|
||||||
gint *standard_output,
|
gint *standard_output,
|
||||||
gint *standard_error,
|
gint *standard_error,
|
||||||
@ -225,7 +225,7 @@ g_spawn_async (const gchar *working_directory,
|
|||||||
GSpawnFlags flags,
|
GSpawnFlags flags,
|
||||||
GSpawnChildSetupFunc child_setup,
|
GSpawnChildSetupFunc child_setup,
|
||||||
gpointer user_data,
|
gpointer user_data,
|
||||||
gint *child_handle,
|
GPid *child_handle,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (argv != NULL, FALSE);
|
g_return_val_if_fail (argv != NULL, FALSE);
|
||||||
@ -316,7 +316,7 @@ g_spawn_sync (const gchar *working_directory,
|
|||||||
{
|
{
|
||||||
gint outpipe = -1;
|
gint outpipe = -1;
|
||||||
gint errpipe = -1;
|
gint errpipe = -1;
|
||||||
gint pid;
|
GPid pid;
|
||||||
GIOChannel *outchannel = NULL;
|
GIOChannel *outchannel = NULL;
|
||||||
GIOChannel *errchannel = NULL;
|
GIOChannel *errchannel = NULL;
|
||||||
GPollFD outfd, errfd;
|
GPollFD outfd, errfd;
|
||||||
@ -492,6 +492,8 @@ g_spawn_sync (const gchar *working_directory,
|
|||||||
if (errpipe >= 0)
|
if (errpipe >= 0)
|
||||||
close_and_invalidate (&errpipe);
|
close_and_invalidate (&errpipe);
|
||||||
|
|
||||||
|
g_spawn_close_pid(pid);
|
||||||
|
|
||||||
if (failed)
|
if (failed)
|
||||||
{
|
{
|
||||||
if (outstr)
|
if (outstr)
|
||||||
@ -523,7 +525,7 @@ g_spawn_async_with_pipes (const gchar *working_directory,
|
|||||||
GSpawnFlags flags,
|
GSpawnFlags flags,
|
||||||
GSpawnChildSetupFunc child_setup,
|
GSpawnChildSetupFunc child_setup,
|
||||||
gpointer user_data,
|
gpointer user_data,
|
||||||
gint *child_handle,
|
GPid *child_handle,
|
||||||
gint *standard_input,
|
gint *standard_input,
|
||||||
gint *standard_output,
|
gint *standard_output,
|
||||||
gint *standard_error,
|
gint *standard_error,
|
||||||
@ -869,7 +871,7 @@ do_spawn_with_pipes (gboolean dont_wait,
|
|||||||
gboolean file_and_argv_zero,
|
gboolean file_and_argv_zero,
|
||||||
GSpawnChildSetupFunc child_setup,
|
GSpawnChildSetupFunc child_setup,
|
||||||
gpointer user_data,
|
gpointer user_data,
|
||||||
gint *child_handle,
|
GPid *child_handle,
|
||||||
gint *standard_input,
|
gint *standard_input,
|
||||||
gint *standard_output,
|
gint *standard_output,
|
||||||
gint *standard_error,
|
gint *standard_error,
|
||||||
@ -1036,5 +1038,10 @@ make_pipe (gint p[2],
|
|||||||
else
|
else
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* !GSPAWN_HELPER */
|
#endif /* !GSPAWN_HELPER */
|
||||||
|
|
||||||
|
void
|
||||||
|
g_spawn_close_pid (GPid pid)
|
||||||
|
{
|
||||||
|
CloseHandle (pid);
|
||||||
|
}
|
||||||
|
@ -58,7 +58,7 @@ static gboolean fork_exec_with_pipes (gboolean intermediate_child,
|
|||||||
gboolean file_and_argv_zero,
|
gboolean file_and_argv_zero,
|
||||||
GSpawnChildSetupFunc child_setup,
|
GSpawnChildSetupFunc child_setup,
|
||||||
gpointer user_data,
|
gpointer user_data,
|
||||||
gint *child_pid,
|
GPid *child_pid,
|
||||||
gint *standard_input,
|
gint *standard_input,
|
||||||
gint *standard_output,
|
gint *standard_output,
|
||||||
gint *standard_error,
|
gint *standard_error,
|
||||||
@ -96,7 +96,7 @@ g_spawn_async (const gchar *working_directory,
|
|||||||
GSpawnFlags flags,
|
GSpawnFlags flags,
|
||||||
GSpawnChildSetupFunc child_setup,
|
GSpawnChildSetupFunc child_setup,
|
||||||
gpointer user_data,
|
gpointer user_data,
|
||||||
gint *child_pid,
|
GPid *child_pid,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (argv != NULL, FALSE);
|
g_return_val_if_fail (argv != NULL, FALSE);
|
||||||
@ -213,7 +213,7 @@ g_spawn_sync (const gchar *working_directory,
|
|||||||
{
|
{
|
||||||
gint outpipe = -1;
|
gint outpipe = -1;
|
||||||
gint errpipe = -1;
|
gint errpipe = -1;
|
||||||
gint pid;
|
GPid pid;
|
||||||
fd_set fds;
|
fd_set fds;
|
||||||
gint ret;
|
gint ret;
|
||||||
GString *outstr = NULL;
|
GString *outstr = NULL;
|
||||||
@ -535,6 +535,9 @@ g_spawn_sync (const gchar *working_directory,
|
|||||||
*
|
*
|
||||||
* If an error occurs, @child_pid, @standard_input, @standard_output,
|
* If an error occurs, @child_pid, @standard_input, @standard_output,
|
||||||
* and @standard_error will not be filled with valid values.
|
* 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
|
* Return value: %TRUE on success, %FALSE if an error was set
|
||||||
**/
|
**/
|
||||||
@ -545,7 +548,7 @@ g_spawn_async_with_pipes (const gchar *working_directory,
|
|||||||
GSpawnFlags flags,
|
GSpawnFlags flags,
|
||||||
GSpawnChildSetupFunc child_setup,
|
GSpawnChildSetupFunc child_setup,
|
||||||
gpointer user_data,
|
gpointer user_data,
|
||||||
gint *child_pid,
|
GPid *child_pid,
|
||||||
gint *standard_input,
|
gint *standard_input,
|
||||||
gint *standard_output,
|
gint *standard_output,
|
||||||
gint *standard_error,
|
gint *standard_error,
|
||||||
@ -1024,13 +1027,13 @@ fork_exec_with_pipes (gboolean intermediate_child,
|
|||||||
gboolean file_and_argv_zero,
|
gboolean file_and_argv_zero,
|
||||||
GSpawnChildSetupFunc child_setup,
|
GSpawnChildSetupFunc child_setup,
|
||||||
gpointer user_data,
|
gpointer user_data,
|
||||||
gint *child_pid,
|
GPid *child_pid,
|
||||||
gint *standard_input,
|
gint *standard_input,
|
||||||
gint *standard_output,
|
gint *standard_output,
|
||||||
gint *standard_error,
|
gint *standard_error,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
gint pid = -1;
|
GPid pid = -1;
|
||||||
gint stdin_pipe[2] = { -1, -1 };
|
gint stdin_pipe[2] = { -1, -1 };
|
||||||
gint stdout_pipe[2] = { -1, -1 };
|
gint stdout_pipe[2] = { -1, -1 };
|
||||||
gint stderr_pipe[2] = { -1, -1 };
|
gint stderr_pipe[2] = { -1, -1 };
|
||||||
@ -1093,7 +1096,7 @@ fork_exec_with_pipes (gboolean intermediate_child,
|
|||||||
* is to exit, so we can waitpid() it immediately.
|
* is to exit, so we can waitpid() it immediately.
|
||||||
* Then the grandchild will not become a zombie.
|
* Then the grandchild will not become a zombie.
|
||||||
*/
|
*/
|
||||||
gint grandchild_pid;
|
GPid grandchild_pid;
|
||||||
|
|
||||||
grandchild_pid = fork ();
|
grandchild_pid = fork ();
|
||||||
|
|
||||||
@ -1517,3 +1520,17 @@ g_execute (const gchar *file,
|
|||||||
/* Return the error from the last attempt (probably ENOENT). */
|
/* Return the error from the last attempt (probably ENOENT). */
|
||||||
return -1;
|
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)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
@ -77,7 +77,7 @@ gboolean g_spawn_async (const gchar *working_directory,
|
|||||||
GSpawnFlags flags,
|
GSpawnFlags flags,
|
||||||
GSpawnChildSetupFunc child_setup,
|
GSpawnChildSetupFunc child_setup,
|
||||||
gpointer user_data,
|
gpointer user_data,
|
||||||
gint *child_pid,
|
GPid *child_pid,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
|
|
||||||
@ -90,7 +90,7 @@ gboolean g_spawn_async_with_pipes (const gchar *working_directory,
|
|||||||
GSpawnFlags flags,
|
GSpawnFlags flags,
|
||||||
GSpawnChildSetupFunc child_setup,
|
GSpawnChildSetupFunc child_setup,
|
||||||
gpointer user_data,
|
gpointer user_data,
|
||||||
gint *child_pid,
|
GPid *child_pid,
|
||||||
gint *standard_input,
|
gint *standard_input,
|
||||||
gint *standard_output,
|
gint *standard_output,
|
||||||
gint *standard_error,
|
gint *standard_error,
|
||||||
@ -120,6 +120,8 @@ gboolean g_spawn_command_line_sync (const gchar *command_line,
|
|||||||
gboolean g_spawn_command_line_async (const gchar *command_line,
|
gboolean g_spawn_command_line_async (const gchar *command_line,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
|
void g_spawn_close_pid (GPid pid);
|
||||||
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
@ -86,12 +86,12 @@ get_a_child (gint ttl)
|
|||||||
gboolean
|
gboolean
|
||||||
child_watch_callback (GPid pid, gint status, gpointer data)
|
child_watch_callback (GPid pid, gint status, gpointer data)
|
||||||
{
|
{
|
||||||
#ifndef G_OS_WIN32
|
gint ttl = GPOINTER_TO_INT (data);
|
||||||
g_print ("child %d exited, status %d\n", pid, status);
|
|
||||||
#else
|
|
||||||
g_print ("child %p exited, status %d\n", pid, status);
|
|
||||||
|
|
||||||
CloseHandle(pid);
|
#ifndef G_OS_WIN32
|
||||||
|
g_print ("child %d (ttl %d) exited, status %d\n", pid, ttl, status);
|
||||||
|
#else
|
||||||
|
g_print ("child %p (ttl %d) exited, status %d\n", pid, ttl, status);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (--alive == 0)
|
if (--alive == 0)
|
||||||
@ -112,14 +112,15 @@ test_thread (gpointer data)
|
|||||||
|
|
||||||
pid = get_a_child (ttl);
|
pid = get_a_child (ttl);
|
||||||
source = g_child_watch_source_new (pid);
|
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_attach (source, g_main_loop_get_context (new_main_loop));
|
||||||
g_source_unref (source);
|
g_source_unref (source);
|
||||||
|
|
||||||
#ifdef G_OS_WIN32
|
#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
|
#else
|
||||||
g_print ("whee! created pid: %d\n", pid);
|
g_print ("whee! created pid: %d (ttl %d)\n", pid, ttl);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
g_main_loop_run (new_main_loop);
|
g_main_loop_run (new_main_loop);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user