]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/contrib/fileutl.cc
* apt-pkg/deb/dpkgpm.cc:
[apt.git] / apt-pkg / contrib / fileutl.cc
index 7c9f5c0dd5470b16520512a2e9d707778405fa5d..d19a92e62cc107b44bb1e103dca047cba0dd74af 100644 (file)
    ##################################################################### */
                                                                        /*}}}*/
 // Include Files                                                       /*{{{*/
    ##################################################################### */
                                                                        /*}}}*/
 // Include Files                                                       /*{{{*/
-#ifdef __GNUG__
-#pragma implementation "apt-pkg/fileutl.h"
-#endif 
 #include <apt-pkg/fileutl.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/sptr.h>
 #include <apt-pkg/fileutl.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/sptr.h>
+#include <apt-pkg/configuration.h>
 
 #include <apti18n.h>
 
 
 #include <apti18n.h>
 
+#include <cstdlib>
 #include <iostream>
 #include <unistd.h>
 #include <fcntl.h>
 #include <iostream>
 #include <unistd.h>
 #include <fcntl.h>
@@ -32,6 +31,7 @@
 #include <sys/wait.h>
 #include <signal.h>
 #include <errno.h>
 #include <sys/wait.h>
 #include <signal.h>
 #include <errno.h>
+#include <set>
                                                                        /*}}}*/
 
 using namespace std;
                                                                        /*}}}*/
 
 using namespace std;
@@ -326,10 +326,27 @@ pid_t ExecFork()
       signal(SIGWINCH,SIG_DFL);
       signal(SIGCONT,SIG_DFL);
       signal(SIGTSTP,SIG_DFL);
       signal(SIGWINCH,SIG_DFL);
       signal(SIGCONT,SIG_DFL);
       signal(SIGTSTP,SIG_DFL);
-      
+
+      set<int> KeepFDs;
+      Configuration::Item const *Opts = _config->Tree("APT::Keep-Fds");
+      if (Opts != 0 && Opts->Child != 0)
+      {
+        Opts = Opts->Child;
+        for (; Opts != 0; Opts = Opts->Next)
+        {
+           if (Opts->Value.empty() == true)
+              continue;
+           int fd = atoi(Opts->Value.c_str());
+           KeepFDs.insert(fd);
+        }
+      }
+
       // Close all of our FDs - just in case
       for (int K = 3; K != 40; K++)
       // Close all of our FDs - just in case
       for (int K = 3; K != 40; K++)
-        fcntl(K,F_SETFD,FD_CLOEXEC);
+      {
+        if(KeepFDs.find(K) == KeepFDs.end())
+           fcntl(K,F_SETFD,FD_CLOEXEC);
+      }
    }
    
    return Process;
    }
    
    return Process;
@@ -355,7 +372,7 @@ bool ExecWait(pid_t Pid,const char *Name,bool Reap)
       if (Reap == true)
         return false;
       
       if (Reap == true)
         return false;
       
-      return _error->Error(_("Waited, for %s but it wasn't there"),Name);
+      return _error->Error(_("Waited for %s but it wasn't there"),Name);
    }
 
    
    }