mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-09-06 16:08:43 +02:00
gstdio: Add support for the e
flag (O_CLOEXEC) to g_fopen()
This adds cross-platform support for it: on glibc, musl and BSD’s libc, the flag is natively supported. On Windows, convert it to the `N` flag, which similarly indicates that an open file shouldn’t be inherited by child processes. This allows us to unconditionally pass `e` to `g_fopen()` so `O_CLOEXEC` can easily be set on its FDs. Also do the same for `g_freopen()`, since it shares the same underlying mode handling code. Signed-off-by: Philip Withnall <pwithnall@gnome.org>
This commit is contained in:
@@ -792,7 +792,7 @@ test_internal_enhanced_stdio (void)
|
||||
|
||||
g_remove (ps);
|
||||
|
||||
f = g_fopen (ps, "wb");
|
||||
f = g_fopen (ps, "wbe");
|
||||
g_assert_nonnull (f);
|
||||
|
||||
h = (HANDLE) _get_osfhandle (fileno (f));
|
||||
@@ -875,7 +875,7 @@ test_internal_enhanced_stdio (void)
|
||||
|
||||
g_assert_true (SystemTimeToFileTime (&st, &ft));
|
||||
|
||||
f = g_fopen (p0, "w");
|
||||
f = g_fopen (p0, "we");
|
||||
g_assert_nonnull (f);
|
||||
|
||||
h = (HANDLE) _get_osfhandle (fileno (f));
|
||||
@@ -888,7 +888,7 @@ test_internal_enhanced_stdio (void)
|
||||
|
||||
fclose (f);
|
||||
|
||||
f = g_fopen (p1, "w");
|
||||
f = g_fopen (p1, "we");
|
||||
g_assert_nonnull (f);
|
||||
|
||||
fclose (f);
|
||||
|
Reference in New Issue
Block a user