From b38bb727530a7e836689ef100b07926522066986 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 15 Mar 2013 14:49:05 +0100 Subject: don't close stdout/stderr if it is also the statusfd --- apt-pkg/contrib/gpgv.cc | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/contrib/gpgv.cc b/apt-pkg/contrib/gpgv.cc index 9760bd21f..94a1f8778 100644 --- a/apt-pkg/contrib/gpgv.cc +++ b/apt-pkg/contrib/gpgv.cc @@ -2,14 +2,13 @@ // Include Files /*{{{*/ #include -#include -#include -#include +#include +#include #include #include #include -#include -#include + +#include #include #include @@ -85,12 +84,12 @@ void ExecGPGV(std::string const &File, std::string const &FileGPG, Args.push_back(gpgvpath.c_str()); Args.push_back("--ignore-time-conflict"); + char statusfdstr[10]; if (statusfd != -1) { Args.push_back("--status-fd"); - char fd[10]; - snprintf(fd, sizeof(fd), "%i", statusfd); - Args.push_back(fd); + snprintf(statusfdstr, sizeof(fd), "%i", statusfd); + Args.push_back(statusfdstr); } for (vector::const_iterator K = keyrings.begin(); @@ -131,8 +130,10 @@ void ExecGPGV(std::string const &File, std::string const &FileGPG, int const nullfd = open("/dev/null", O_RDONLY); close(fd[0]); // Redirect output to /dev/null; we read from the status fd - dup2(nullfd, STDOUT_FILENO); - dup2(nullfd, STDERR_FILENO); + if (statusfd != STDOUT_FILENO) + dup2(nullfd, STDOUT_FILENO); + if (statusfd != STDERR_FILENO) + dup2(nullfd, STDERR_FILENO); // Redirect the pipe to the status fd (3) dup2(fd[1], statusfd); -- cgit v1.2.3