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
This commit is contained in:
Matthias Clasen 2016-07-21 11:52:51 -04:00
parent ad669500a6
commit d5efa64539

View File

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