Don't check for O_CLOEXEC O_CLOEXEC was introduced in POSIX.2008; we can assume it's supported on all systems these days.
diff --git a/gio/gdbusauthmechanismsha1.c b/gio/gdbusauthmechanismsha1.c index 1ed1be6..453c364 100644 --- a/gio/gdbusauthmechanismsha1.c +++ b/gio/gdbusauthmechanismsha1.c
@@ -37,10 +37,6 @@ #include "gwin32sid.h" #endif -#ifndef O_CLOEXEC -#define O_CLOEXEC 0 -#endif - #include "gdbusauthmechanismsha1.h" #include "gcredentials.h" #include "gdbuserror.h"
diff --git a/gio/gdocumentportal.c b/gio/gdocumentportal.c index 8d181a5..57fbe4a 100644 --- a/gio/gdocumentportal.c +++ b/gio/gdocumentportal.c
@@ -33,12 +33,6 @@ #include "gunixfdlist.h" #endif -#ifndef O_CLOEXEC -#define O_CLOEXEC 0 -#else -#define HAVE_O_CLOEXEC 1 -#endif - static gboolean get_document_portal (GXdpDocuments **documents, char **documents_mountpoint, @@ -167,9 +161,6 @@ } if (fd >= 0) { -#ifndef HAVE_O_CLOEXEC - fcntl (fd, F_SETFD, FD_CLOEXEC); -#endif idx = g_unix_fd_list_append (fd_list, fd, NULL); close (fd); }
diff --git a/gio/glocalfile.c b/gio/glocalfile.c index 58af717..9c82eef 100644 --- a/gio/glocalfile.c +++ b/gio/glocalfile.c
@@ -51,10 +51,6 @@ #define O_BINARY 0 #endif -#ifndef O_CLOEXEC -#define O_CLOEXEC 0 -#endif - #include "gfileattribute.h" #include "glocalfile.h" #include "glocalfileinfo.h"
diff --git a/gio/glocalfileinfo.c b/gio/glocalfileinfo.c index eea2668..04e25b7 100644 --- a/gio/glocalfileinfo.c +++ b/gio/glocalfileinfo.c
@@ -92,10 +92,6 @@ #endif #endif -#ifndef O_CLOEXEC -#define O_CLOEXEC 0 -#endif - #include "glocalfileinfo.h" #include "gioerror.h" #include "gthemedicon.h"
diff --git a/gio/glocalfileoutputstream.c b/gio/glocalfileoutputstream.c index fda643b..14652bd 100644 --- a/gio/glocalfileoutputstream.c +++ b/gio/glocalfileoutputstream.c
@@ -65,12 +65,6 @@ #define O_BINARY 0 #endif -#ifndef O_CLOEXEC -#define O_CLOEXEC 0 -#else -#define HAVE_O_CLOEXEC 1 -#endif - struct _GLocalFileOutputStreamPrivate { char *tmp_filename; char *original_filename; @@ -1315,10 +1309,6 @@ set_error_from_open_errno (filename, error); return NULL; } -#if !defined(HAVE_O_CLOEXEC) && defined(F_SETFD) - else - fcntl (fd, F_SETFD, FD_CLOEXEC); -#endif stream = g_object_new (G_TYPE_LOCAL_FILE_OUTPUT_STREAM, NULL); stream->priv->fd = fd;
diff --git a/gio/gopenuriportal.c b/gio/gopenuriportal.c index c0e2353..2017c60 100644 --- a/gio/gopenuriportal.c +++ b/gio/gopenuriportal.c
@@ -33,12 +33,6 @@ #include "gunixfdlist.h" #endif -#ifndef O_CLOEXEC -#define O_CLOEXEC 0 -#else -#define HAVE_O_CLOEXEC 1 -#endif - gboolean g_openuri_portal_open_file (GFile *file, const char *parent_window, @@ -90,9 +84,6 @@ return FALSE; } -#ifndef HAVE_O_CLOEXEC - fcntl (fd, F_SETFD, FD_CLOEXEC); -#endif fd_list = g_unix_fd_list_new_from_array (&fd, 1); fd = -1; fd_id = 0; @@ -363,9 +354,6 @@ return; } -#ifndef HAVE_O_CLOEXEC - fcntl (fd, F_SETFD, FD_CLOEXEC); -#endif fd_list = g_unix_fd_list_new_from_array (&fd, 1); fd = -1; fd_id = 0;
diff --git a/gio/gsubprocess.c b/gio/gsubprocess.c index dad32da..7b2643b 100644 --- a/gio/gsubprocess.c +++ b/gio/gsubprocess.c
@@ -115,12 +115,6 @@ #define O_BINARY 0 #endif -#ifndef O_CLOEXEC -#define O_CLOEXEC 0 -#else -#define HAVE_O_CLOEXEC 1 -#endif - #define COMMUNICATE_READ_SIZE 4096 /* A GSubprocess can have two possible states: running and not. @@ -235,10 +229,6 @@ g_free (display_name); /* fall through... */ } -#ifndef HAVE_O_CLOEXEC - else - fcntl (my_fd, F_SETFD, FD_CLOEXEC); -#endif return my_fd; }
diff --git a/gio/gtrashportal.c b/gio/gtrashportal.c index 82c1356..5d46d24 100644 --- a/gio/gtrashportal.c +++ b/gio/gtrashportal.c
@@ -33,12 +33,6 @@ #include "gunixfdlist.h" #endif -#ifndef O_CLOEXEC -#define O_CLOEXEC 0 -#else -#define HAVE_O_CLOEXEC 1 -#endif - #ifndef O_PATH #define O_PATH 0 #endif @@ -107,10 +101,6 @@ goto out; } -#ifndef HAVE_O_CLOEXEC - fcntl (fd, F_SETFD, FD_CLOEXEC); -#endif - fd_list = g_unix_fd_list_new (); fd_in = g_unix_fd_list_append (fd_list, fd, error); g_close (fd, NULL);
diff --git a/gio/kqueue/gkqueuefilemonitor.c b/gio/kqueue/gkqueuefilemonitor.c index b664753..e1d4a7b 100644 --- a/gio/kqueue/gkqueuefilemonitor.c +++ b/gio/kqueue/gkqueuefilemonitor.c
@@ -32,10 +32,6 @@ #include <fcntl.h> #include <string.h> -#ifndef O_CLOEXEC -#define O_CLOEXEC 0 -#endif - #include <glib-object.h> #include <glib/gfileutils.h> #include <gio/gfilemonitor.h>
diff --git a/gio/tests/gsubprocess-testprog.c b/gio/tests/gsubprocess-testprog.c index b61ccc2..3b19227 100644 --- a/gio/tests/gsubprocess-testprog.c +++ b/gio/tests/gsubprocess-testprog.c
@@ -124,12 +124,6 @@ return 0; } -#ifdef G_OS_UNIX -#define GLIB_FD_CLOEXEC "e" -#else -#define GLIB_FD_CLOEXEC "" -#endif - static int write_to_fds (int argc, char **argv) { @@ -138,7 +132,7 @@ for (i = 2; i < argc; i++) { int fd = atoi (argv[i]); - FILE *f = fdopen (fd, "w" GLIB_FD_CLOEXEC); + FILE *f = fdopen (fd, "we"); const char buf[] = "hello world\n"; size_t bytes_written; @@ -176,7 +170,7 @@ return 1; } - f = fdopen (fd, "r" GLIB_FD_CLOEXEC); + f = fdopen (fd, "re"); if (f == NULL) { g_warning ("Failed to open fd %d: %s", fd, g_strerror (errno));
diff --git a/glib/gfileutils.c b/glib/gfileutils.c index 472be65..e177aaa 100644 --- a/glib/gfileutils.c +++ b/glib/gfileutils.c
@@ -49,10 +49,6 @@ #define O_BINARY 0 #endif -#ifndef O_CLOEXEC -#define O_CLOEXEC 0 -#endif - #include "gfileutils.h" #include "gstdio.h"
diff --git a/glib/giounix.c b/glib/giounix.c index a5b8605..41c6e27 100644 --- a/glib/giounix.c +++ b/glib/giounix.c
@@ -44,10 +44,6 @@ #include <fcntl.h> #include <glib/gstdio.h> -#ifndef O_CLOEXEC -#define O_CLOEXEC 0 -#endif - #include "giochannel.h" #include "gerror.h"
diff --git a/glib/gkeyfile.c b/glib/gkeyfile.c index f5b600b..0df69e8 100644 --- a/glib/gkeyfile.c +++ b/glib/gkeyfile.c
@@ -53,10 +53,6 @@ #endif /* G_OS_WIN23 */ -#ifndef O_CLOEXEC -#define O_CLOEXEC 0 -#endif - #include "gconvert.h" #include "gdataset.h" #include "gerror.h"
diff --git a/glib/gmappedfile.c b/glib/gmappedfile.c index 222e057..80e2e84 100644 --- a/glib/gmappedfile.c +++ b/glib/gmappedfile.c
@@ -50,10 +50,6 @@ #endif -#ifndef O_CLOEXEC -#define O_CLOEXEC 0 -#endif - #include "gconvert.h" #include "gerror.h" #include "gfileutils.h"
diff --git a/glib/gspawn-posix.c b/glib/gspawn-posix.c index 8cbf8de..7a00667 100644 --- a/glib/gspawn-posix.c +++ b/glib/gspawn-posix.c
@@ -111,12 +111,6 @@ extern char **environ; #endif -#ifndef O_CLOEXEC -#define O_CLOEXEC 0 -#else -#define HAVE_O_CLOEXEC 1 -#endif - static gint g_execute (const gchar *file, gchar **argv, gchar **argv_buffer, @@ -1093,10 +1087,6 @@ g_assert (read_null != -1); parent_close_fds[num_parent_close_fds++] = read_null; -#ifndef HAVE_O_CLOEXEC - fcntl (read_null, F_SETFD, FD_CLOEXEC); -#endif - r = posix_spawn_file_actions_adddup2 (&file_actions, read_null, 0); if (r != 0) goto out_close_fds; @@ -1117,10 +1107,6 @@ g_assert (write_null != -1); parent_close_fds[num_parent_close_fds++] = write_null; -#ifndef HAVE_O_CLOEXEC - fcntl (write_null, F_SETFD, FD_CLOEXEC); -#endif - r = posix_spawn_file_actions_adddup2 (&file_actions, write_null, 1); if (r != 0) goto out_close_fds; @@ -1141,10 +1127,6 @@ g_assert (write_null != -1); parent_close_fds[num_parent_close_fds++] = write_null; -#ifndef HAVE_O_CLOEXEC - fcntl (write_null, F_SETFD, FD_CLOEXEC); -#endif - r = posix_spawn_file_actions_adddup2 (&file_actions, write_null, 2); if (r != 0) goto out_close_fds;
diff --git a/gmodule/gmodule.c b/gmodule/gmodule.c index a6804d3..5b370b7 100644 --- a/gmodule/gmodule.c +++ b/gmodule/gmodule.c
@@ -51,10 +51,6 @@ #include <io.h> /* For open() and close() prototypes. */ #endif -#ifndef O_CLOEXEC -#define O_CLOEXEC 0 -#endif - #include "gmoduleconf.h" #include "gstdio.h"