diff options
Diffstat (limited to 'apt-pkg')
-rw-r--r-- | apt-pkg/contrib/fileutl.cc | 8 | ||||
-rw-r--r-- | apt-pkg/contrib/fileutl.h | 3 | ||||
-rw-r--r-- | apt-pkg/contrib/proxy.cc | 2 |
3 files changed, 11 insertions, 2 deletions
diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index 20ccaa1c6..df39ae160 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -2804,6 +2804,11 @@ bool Rename(std::string From, std::string To) /*{{{*/ /*}}}*/ bool Popen(const char* Args[], FileFd &Fd, pid_t &Child, FileFd::OpenMode Mode)/*{{{*/ { + return Popen(Args, Fd, Child, Mode, true); +} + /*}}}*/ +bool Popen(const char* Args[], FileFd &Fd, pid_t &Child, FileFd::OpenMode Mode, bool CaptureStderr)/*{{{*/ +{ int fd; if (Mode != FileFd::ReadOnly && Mode != FileFd::WriteOnly) return _error->Error("Popen supports ReadOnly (x)or WriteOnly mode only"); @@ -2834,7 +2839,8 @@ bool Popen(const char* Args[], FileFd &Fd, pid_t &Child, FileFd::OpenMode Mode)/ if(Mode == FileFd::ReadOnly) { dup2(fd, 1); - dup2(fd, 2); + if (CaptureStderr == true) + dup2(fd, 2); } else if(Mode == FileFd::WriteOnly) dup2(fd, 0); diff --git a/apt-pkg/contrib/fileutl.h b/apt-pkg/contrib/fileutl.h index 9333b8d5f..7ee302d7b 100644 --- a/apt-pkg/contrib/fileutl.h +++ b/apt-pkg/contrib/fileutl.h @@ -245,8 +245,11 @@ std::vector<std::string> Glob(std::string const &pattern, int flags=0); * \param Child a reference to the integer that stores the child pid * Note that you must call ExecWait() or similar to cleanup * \param Mode is either FileFd::ReadOnly or FileFd::WriteOnly + * \param CaptureStderr True if we should capture stderr in addition to stdout. + * (default: True). * \return true on success, false on failure with _error set */ +bool Popen(const char* Args[], FileFd &Fd, pid_t &Child, FileFd::OpenMode Mode, bool CaptureStderr); bool Popen(const char* Args[], FileFd &Fd, pid_t &Child, FileFd::OpenMode Mode); diff --git a/apt-pkg/contrib/proxy.cc b/apt-pkg/contrib/proxy.cc index 84d802dcb..13a6ab940 100644 --- a/apt-pkg/contrib/proxy.cc +++ b/apt-pkg/contrib/proxy.cc @@ -48,7 +48,7 @@ bool AutoDetectProxy(URI &URL) Args.push_back(nullptr); FileFd PipeFd; pid_t Child; - if(Popen(&Args[0], PipeFd, Child, FileFd::ReadOnly) == false) + if(Popen(&Args[0], PipeFd, Child, FileFd::ReadOnly, false) == false) return _error->Error("ProxyAutoDetect command '%s' failed!", AutoDetectProxyCmd.c_str()); char buf[512]; if (PipeFd.ReadLine(buf, sizeof(buf)) == nullptr) |