summaryrefslogtreecommitdiff
path: root/apt-pkg/contrib/fileutl.cc
diff options
context:
space:
mode:
authorMichael Vogt <mvo@debian.org>2013-10-31 22:55:38 +0100
committerMichael Vogt <mvo@debian.org>2013-10-31 22:55:38 +0100
commite45c4617e496b49f8d7225546a751022f246a2f3 (patch)
tree19fa436f3760c896d997baedb89fd128594279ce /apt-pkg/contrib/fileutl.cc
parent177296dffd8bf7d9ce5870b135c412958aab3756 (diff)
add new pid_t ExecFork(std::set<int> KeepFDs) to get rid of the super ugly APT::Keep-Fds hack and also add a new PackageManagerProgressFd::StartDpkg() progress state
Diffstat (limited to 'apt-pkg/contrib/fileutl.cc')
-rw-r--r--apt-pkg/contrib/fileutl.cc33
1 files changed, 19 insertions, 14 deletions
diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc
index 0261119ba..2347ef140 100644
--- a/apt-pkg/contrib/fileutl.cc
+++ b/apt-pkg/contrib/fileutl.cc
@@ -767,6 +767,25 @@ bool WaitFd(int Fd,bool write,unsigned long timeout)
otherwise acts like normal fork. */
pid_t ExecFork()
{
+ 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);
+ }
+ }
+ return ExecFork(KeepFDs);
+}
+
+pid_t ExecFork(std::set<int> KeepFDs)
+{
// Fork off the process
pid_t Process = fork();
if (Process < 0)
@@ -786,20 +805,6 @@ pid_t ExecFork()
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++)
{