mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-29 12:24:12 +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:
@@ -1131,7 +1131,7 @@ main (int argc, char **argv)
|
||||
{
|
||||
FILE *file;
|
||||
|
||||
file = fopen (target, "w");
|
||||
file = g_fopen (target, "we");
|
||||
if (file == NULL)
|
||||
{
|
||||
g_printerr ("can't write to file %s", target);
|
||||
@@ -1180,7 +1180,7 @@ main (int argc, char **argv)
|
||||
}
|
||||
g_unlink (binary_target);
|
||||
|
||||
file = fopen (target, "w");
|
||||
file = g_fopen (target, "we");
|
||||
if (file == NULL)
|
||||
{
|
||||
g_printerr ("can't write to file %s", target);
|
||||
|
Reference in New Issue
Block a user