1
0
mirror of https://gitlab.gnome.org/GNOME/glib.git synced 2026-10-24 00:49:00 +03:00

Don't check for O_CLOEXEC

O_CLOEXEC was introduced in POSIX.2008; we can assume it's
supported on all systems these days.
This commit is contained in:
Luca Bacci
2026-08-24 11:45:43 +02:00
parent 016428f9bc
commit 38647c97b1
16 changed files with 2 additions and 113 deletions

View File

@@ -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"

View File

@@ -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 @@ g_document_portal_add_documents (GList *uris,
}
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);
}

View File

@@ -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"

View File

@@ -92,10 +92,6 @@
#endif
#endif
#ifndef O_CLOEXEC
#define O_CLOEXEC 0
#endif
#include "glocalfileinfo.h"
#include "gioerror.h"
#include "gthemedicon.h"

View File

@@ -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 @@ _g_local_file_output_stream_replace (const char *filename,
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;

View File

@@ -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 @@ g_openuri_portal_open_file (GFile *file,
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 @@ g_openuri_portal_open_file_async (GFile *file,
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;

View File

@@ -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 @@ unix_open_file (const char *filename,
g_free (display_name);
/* fall through... */
}
#ifndef HAVE_O_CLOEXEC
else
fcntl (my_fd, F_SETFD, FD_CLOEXEC);
#endif
return my_fd;
}

View File

@@ -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 @@ g_trash_portal_trash_file (GFile *file,
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);

View File

@@ -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>

View File

@@ -124,12 +124,6 @@ sleep_forever_mode (int argc,
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 @@ write_to_fds (int argc, char **argv)
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 @@ read_from_fd (int argc, char **argv)
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));

View File

@@ -49,10 +49,6 @@
#define O_BINARY 0
#endif
#ifndef O_CLOEXEC
#define O_CLOEXEC 0
#endif
#include "gfileutils.h"
#include "gstdio.h"

View File

@@ -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"

View File

@@ -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"

View File

@@ -50,10 +50,6 @@
#endif
#ifndef O_CLOEXEC
#define O_CLOEXEC 0
#endif
#include "gconvert.h"
#include "gerror.h"
#include "gfileutils.h"

View File

@@ -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 @@ do_posix_spawn (const gchar * const *argv,
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 @@ do_posix_spawn (const gchar * const *argv,
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 @@ do_posix_spawn (const gchar * const *argv,
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;

View File

@@ -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"