Stop setting FD_CLOEXEC on systems where O_CLOEXEC is honored

In commit 85ff351266, 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>
This commit is contained in:
Thiago Macieira 2017-07-17 18:54:00 -07:00
parent cb9b42b493
commit 42d2464d8f

View File

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