]> git.saurik.com Git - apt.git/commitdiff
Move sysconf(_SC_OPEN_MAX); out of the for() loop to avoid unneeded syscalls
authorMichael Vogt <mvo@debian.org>
Tue, 28 Apr 2015 15:55:00 +0000 (17:55 +0200)
committerMichael Vogt <mvo@debian.org>
Tue, 28 Apr 2015 15:55:00 +0000 (17:55 +0200)
apt-pkg/contrib/fileutl.cc

index 1ba4674e583194155be2477097188fff8775e19f..1e6d96fe91e0904b75a4fac6b5eb9a307cf14e8f 100644 (file)
@@ -778,8 +778,9 @@ pid_t ExecFork(std::set<int> KeepFDs)
       signal(SIGCONT,SIG_DFL);
       signal(SIGTSTP,SIG_DFL);
 
+      long ScOpenMax = sysconf(_SC_OPEN_MAX);
       // Close all of our FDs - just in case
-      for (int K = 3; K != sysconf(_SC_OPEN_MAX); K++)
+      for (int K = 3; K != ScOpenMax; K++)
       {
         if(KeepFDs.find(K) == KeepFDs.end())
            fcntl(K,F_SETFD,FD_CLOEXEC);