#ifndef APT_8_CLEANER_HEADERS
 #include <apt-pkg/acquire.h>
-// include pkg{DistUpgrade,AllUpgrade,MiniizeUpgrade} here for compatiblity
 using std::ostream;
 #endif
 
 #ifndef APT_9_CLEANER_HEADERS
+// include pkg{DistUpgrade,AllUpgrade,MiniizeUpgrade} here for compatiblity
 #include <apt-pkg/upgrade.h>
 #include <apt-pkg/update.h>
 #endif
 
 {
       set<int> KeepFDs;
 
+      // FIXME: remove looking at APT::Keep-Fds eventually, its a hack
       Configuration::Item const *Opts = _config->Tree("APT::Keep-Fds");
       if (Opts != 0 && Opts->Child != 0)
       {
       signal(SIGTSTP,SIG_DFL);
 
       // Close all of our FDs - just in case
-      for (int K = 3; K != 40; K++)
+      for (int K = 3; K != sysconf(_SC_OPEN_MAX); K++)
       {
         if(KeepFDs.find(K) == KeepFDs.end())
            fcntl(K,F_SETFD,FD_CLOEXEC);
 
 namespace APT {
 namespace Progress {
 
+
+/* Return a APT::Progress::PackageManager based on the global
+ * apt configuration (i.e. APT::Status-Fd and APT::Status-deb822-Fd)
+ */
 PackageManager* PackageManagerProgressFactory()
 {
    // select the right progress
 
   * prepare next ABI via #if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13)
   * add new pid_t ExecFork(std::set<int> KeepFDs)
   * Avoid flickering when "apt-get -o DpkgPM::Progress-Fancy=1" is use
+  * use sysconf(_SC_OPEN_MAX) in ExecFork()
 
  -- Michael Vogt <mvo@debian.org>  Fri, 01 Nov 2013 10:03:06 +0100