OSDN Git Service

remove unused qt_safe_dup() and qt_safe_dup2() arguments
authorIvailo Monev <xakepa10@laimg.moc>
Mon, 30 Mar 2020 18:03:34 +0000 (18:03 +0000)
committerIvailo Monev <xakepa10@laimg.moc>
Mon, 30 Mar 2020 18:03:34 +0000 (18:03 +0000)
Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
src/core/io/qprocess_unix.cpp
src/core/kernel/qcore_unix_p.h

index 6f9a9ad..ee7e57f 100644 (file)
@@ -678,17 +678,17 @@ void QProcessPrivate::execChild(const char *workingDir, char **path, char **argv
     Q_Q(QProcess);
 
     // copy the stdin socket (without closing on exec)
-    qt_safe_dup2(stdinChannel.pipe[0], STDIN_FILENO, 0);
+    qt_safe_dup2(stdinChannel.pipe[0], STDIN_FILENO);
 
     // copy the stdout and stderr if asked to
     if (processChannelMode != QProcess::ForwardedChannels) {
-        qt_safe_dup2(stdoutChannel.pipe[1], STDOUT_FILENO, 0);
+        qt_safe_dup2(stdoutChannel.pipe[1], STDOUT_FILENO);
 
         // merge stdout and stderr if asked to
         if (processChannelMode == QProcess::MergedChannels) {
-            qt_safe_dup2(STDOUT_FILENO, STDERR_FILENO, 0);
+            qt_safe_dup2(STDOUT_FILENO, STDERR_FILENO);
         } else {
-            qt_safe_dup2(stderrChannel.pipe[1], STDERR_FILENO, 0);
+            qt_safe_dup2(stderrChannel.pipe[1], STDERR_FILENO);
         }
     }
 
index fbf6b51..0d2c5f3 100644 (file)
@@ -184,49 +184,32 @@ static inline int qt_safe_pipe(int pipefd[2], int flags = 0)
 }
 
 // don't call dup or fcntl(F_DUPFD)
-static inline int qt_safe_dup(int oldfd, int atleast = 0, int flags = FD_CLOEXEC)
+static inline int qt_safe_dup(int oldfd)
 {
-    Q_ASSERT(flags == FD_CLOEXEC || flags == 0);
-
     int ret;
 #ifdef F_DUPFD_CLOEXEC
     // use this fcntl
-    if (flags & FD_CLOEXEC) {
-        ret = ::fcntl(oldfd, F_DUPFD_CLOEXEC, atleast);
-        if (ret != -1 || errno != EINVAL)
-            return ret;
-    }
+    ret = ::fcntl(oldfd, F_DUPFD_CLOEXEC, 0);
+    if (ret != -1 || errno != EINVAL)
+        return ret;
 #endif
 
     // use F_DUPFD
-    ret = ::fcntl(oldfd, F_DUPFD, atleast);
+    ret = ::fcntl(oldfd, F_DUPFD, 0);
 
-    if (flags && ret != -1)
-        ::fcntl(ret, F_SETFD, flags);
+    if (ret != -1)
+        ::fcntl(ret, F_SETFD, FD_CLOEXEC);
     return ret;
 }
 
 // don't call dup2
 // call qt_safe_dup2
-static inline int qt_safe_dup2(int oldfd, int newfd, int flags = FD_CLOEXEC)
+static inline int qt_safe_dup2(int oldfd, int newfd)
 {
-    Q_ASSERT(flags == FD_CLOEXEC || flags == 0);
-
     int ret;
-#if defined(Q_OS_LINUX) && defined(O_CLOEXEC)
-    // use dup3
-    if (flags & FD_CLOEXEC) {
-        EINTR_LOOP(ret, ::dup3(oldfd, newfd, O_CLOEXEC));
-        if (ret == 0 || errno != ENOSYS)
-            return ret;
-    }
-#endif
     EINTR_LOOP(ret, ::dup2(oldfd, newfd));
     if (ret == -1)
         return -1;
-
-    if (flags)
-        ::fcntl(newfd, F_SETFD, flags);
     return 0;
 }