QFileSystemWatcher/kqueue: make the fd duplication + FD_CLOEXEC atomic

The original fd was already FD_CLOEXEC due to qt_safe_open.

Change-Id: Ief61d358e2b54a0fac37fffd14d2394ee02da059
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
bb10
Thiago Macieira 2017-07-17 13:50:36 -07:00
parent e70258a155
commit d819d6864a
1 changed files with 1 additions and 2 deletions

View File

@ -111,13 +111,12 @@ QStringList QKqueueFileSystemWatcherEngine::addPaths(const QStringList &paths,
continue;
}
if (fd >= (int)FD_SETSIZE / 2 && fd < (int)FD_SETSIZE) {
int fddup = fcntl(fd, F_DUPFD, FD_SETSIZE);
int fddup = qt_safe_dup(fd, FD_SETSIZE);
if (fddup != -1) {
::close(fd);
fd = fddup;
}
}
fcntl(fd, F_SETFD, FD_CLOEXEC);
QT_STATBUF st;
if (QT_FSTAT(fd, &st) == -1) {