mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-07-23 18:37:50 +02:00
glib-unix: Add g_closefrom(), g_fdwalk_set_cloexec()
These are the same as Linux `close_range (lowfd, ~0U, 0)` and `close_range (lowfd, ~0U, CLOSE_RANGE_CLOEXEC)`, but portable. Unlike some implementations of BSD closefrom(3), they are async-signal-safe. The implementations were moved from the GSpawn code, which already needs all of this functionality anyway, with the exception of set_cloexec() which was copied (leading to some minor duplication, but it's very simple). Resolves: https://gitlab.gnome.org/GNOME/glib/-/issues/3247 Signed-off-by: Simon McVittie <smcv@collabora.com>
This commit is contained in:
@@ -326,6 +326,12 @@ g_unix_pipe_clear (GUnixPipe *self)
|
||||
|
||||
G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC (GUnixPipe, g_unix_pipe_clear)
|
||||
|
||||
GLIB_AVAILABLE_IN_2_80
|
||||
int g_closefrom (int lowfd);
|
||||
|
||||
GLIB_AVAILABLE_IN_2_80
|
||||
int g_fdwalk_set_cloexec (int lowfd);
|
||||
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
|
||||
G_END_DECLS
|
||||
|
Reference in New Issue
Block a user