mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-11-11 13:25:36 +01:00
gmain: Add g_steal_fd() to API
This is basically glnx_steal_fd() from libglnx. We already had two private implementations of it in GLib. Signed-off-by: Simon McVittie <smcv@collabora.com>
This commit is contained in:
committed by
Philip Withnall
parent
46c34ea20f
commit
6c5a227bcc
20
glib/gmain.c
20
glib/gmain.c
@@ -6122,3 +6122,23 @@ g_get_worker_context (void)
|
||||
|
||||
return glib_worker_context;
|
||||
}
|
||||
|
||||
/**
|
||||
* g_steal_fd:
|
||||
* @fd_ptr: (not optional) (inout): A pointer to a file descriptor
|
||||
*
|
||||
* Sets @fd_ptr to `-1`, returning the value that was there before.
|
||||
*
|
||||
* Conceptually, this transfers the ownership of the file descriptor
|
||||
* from the referenced variable to the caller of the function (i.e.
|
||||
* ‘steals’ the reference). This is very similar to g_steal_pointer(),
|
||||
* but for file descriptors.
|
||||
*
|
||||
* On POSIX platforms, this function is async-signal safe
|
||||
* (see [`signal(7)`](man:signal(7)) and
|
||||
* [`signal-safety(7)`](man:signal-safety(7))), making it safe to call from a
|
||||
* signal handler or a #GSpawnChildSetupFunc.
|
||||
*
|
||||
* Returns: the value that @fd_ptr previously had
|
||||
* Since: 2.70
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user