gmain: Add private API to create Unix child watch that uses waitid()

This avoids collecting the zombie child, which means that the PID
can't be reused.  This prevents possible race conditions that might
occur were one to send e.g. SIGTERM to a child.

This race condition has always existed due to the way we called
waitpid() for the app, but the window was widened when we moved the
waitpid() calls into a separate thread.

If waitid() isn't available, we return NULL, and consumers of this
private API (namely, GSubprocess) will need to handle that.

https://bugzilla.gnome.org/show_bug.cgi?id=672102
This commit is contained in:
Colin Walters
2012-05-21 17:09:06 -04:00
parent e744a4aa7a
commit 93bf37ce15
4 changed files with 141 additions and 45 deletions

View File

@@ -41,7 +41,8 @@ glib__private__ (void)
g_get_worker_context,
g_check_setuid,
g_main_context_new_with_next_id
g_main_context_new_with_next_id,
g_child_watch_source_new_nowait
};
return &table;