[glib] Deal with lack of O_CLOEXEC



commit d5efa64539f71dc705826e2c0dc4ecb8354b9a77
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu Jul 21 11:52:51 2016 -0400

    Deal with lack of O_CLOEXEC
    
    Some platforms don't have it. We fall back to fcntl() in other
    places, so do it here as well.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=769042

 gio/gdocumentportal.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
---
diff --git a/gio/gdocumentportal.c b/gio/gdocumentportal.c
index d295300..7522d0b 100644
--- a/gio/gdocumentportal.c
+++ b/gio/gdocumentportal.c
@@ -33,6 +33,11 @@
 #ifndef O_PATH
 #define O_PATH 0
 #endif
+#ifndef O_CLOEXEC
+#define O_CLOEXEC 0
+#else
+#define HAVE_O_CLOEXEC 1
+#endif
 
 static GXdpDocuments *documents;
 static char *documents_mountpoint;
@@ -115,6 +120,10 @@ g_document_portal_add_document (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);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]