summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2017-07-17 18:54:00 -0700
committerThiago Macieira <thiago.macieira@intel.com>2017-07-20 01:17:35 +0000
commit42d2464d8fb984f3ff11b6e3ccaae661f8f4e02d (patch)
treeb53bc90273656c5e50b801c6a052fd0b03bf9825 /src/corelib
parentcb9b42b493d168544ec8e4d6ff10c74cbdc70942 (diff)
Stop setting FD_CLOEXEC on systems where O_CLOEXEC is honored
In commit 85ff35126623e6f26c84d9fa8a35b6762aefb110, we removed support for systems where the pipe2(), dup3(), and accept4() functions are declared in the libc headers but fail at runtime. On Linux, O_CLOEXEC was added before accept4(), so if the latter is supported, the former is too. On the BSDs, the libc headers are updated in lockstep with the kernel, so we know for sure. There are still systems that have O_CLOEXEC (a POSIX.1-2008 flag) but not the extra functions (Solaris and Darwin). Solaris libc must update like the BSDs, but on Darwin we do build with a new SDK targeting an old OS. Fortunately, O_CLOEXEC has been supported since 10.7, so we're out of the woods. Change-Id: I84e45059a888497fb55ffffd14d249dd4719e2cc Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/kernel/qcore_unix_p.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/corelib/kernel/qcore_unix_p.h b/src/corelib/kernel/qcore_unix_p.h
index 9d2c4f6c31..f78d2b9f24 100644
--- a/src/corelib/kernel/qcore_unix_p.h
+++ b/src/corelib/kernel/qcore_unix_p.h
@@ -186,10 +186,11 @@ static inline int qt_safe_open(const char *pathname, int flags, mode_t mode = 07
int fd;
EINTR_LOOP(fd, QT_OPEN(pathname, flags, mode));
- // unknown flags are ignored, so we have no way of verifying if
- // O_CLOEXEC was accepted
+#ifndef O_CLOEXEC
if (fd != -1)
::fcntl(fd, F_SETFD, FD_CLOEXEC);
+#endif
+
return fd;
}
#undef QT_OPEN