mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-07 06:40:18 +01:00
glib-aux: add nm_g_child_watch_source_new() and nm_g_child_watch_add_source() helpers
This commit is contained in:
parent
5d08d3a7ef
commit
b7c77d51eb
2 changed files with 31 additions and 0 deletions
|
|
@ -5097,6 +5097,23 @@ nm_g_unix_fd_source_new(int fd,
|
|||
return source;
|
||||
}
|
||||
|
||||
GSource *
|
||||
nm_g_child_watch_source_new(GPid pid,
|
||||
int priority,
|
||||
GChildWatchFunc handler,
|
||||
gpointer user_data,
|
||||
GDestroyNotify notify)
|
||||
{
|
||||
GSource *source;
|
||||
|
||||
source = g_child_watch_source_new(pid);
|
||||
|
||||
if (priority != G_PRIORITY_DEFAULT)
|
||||
g_source_set_priority(source, priority);
|
||||
g_source_set_callback(source, G_SOURCE_FUNC(handler), user_data, notify);
|
||||
return source;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#define _CTX_LOG(fmt, ...) \
|
||||
|
|
|
|||
|
|
@ -1728,6 +1728,12 @@ GSource *nm_g_unix_signal_source_new(int signum,
|
|||
gpointer user_data,
|
||||
GDestroyNotify notify);
|
||||
|
||||
GSource *nm_g_child_watch_source_new(GPid pid,
|
||||
int priority,
|
||||
GChildWatchFunc handler,
|
||||
gpointer user_data,
|
||||
GDestroyNotify notify);
|
||||
|
||||
static inline GSource *
|
||||
nm_g_source_attach(GSource *source, GMainContext *context)
|
||||
{
|
||||
|
|
@ -1824,6 +1830,14 @@ nm_g_unix_signal_add_source(int signum, GSourceFunc handler, gpointer user_data)
|
|||
NULL);
|
||||
}
|
||||
|
||||
static inline GSource *
|
||||
nm_g_child_watch_add_source(GPid pid, GChildWatchFunc handler, gpointer user_data)
|
||||
{
|
||||
return nm_g_source_attach(
|
||||
nm_g_child_watch_source_new(pid, G_PRIORITY_DEFAULT, handler, user_data, NULL),
|
||||
NULL);
|
||||
}
|
||||
|
||||
NM_AUTO_DEFINE_FCN0(GMainContext *, _nm_auto_unref_gmaincontext, g_main_context_unref);
|
||||
#define nm_auto_unref_gmaincontext nm_auto(_nm_auto_unref_gmaincontext)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue