From b8dc791d39033030dd8b7a5ac4925c41d6820540 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 4 Jan 2013 09:36:49 +0100 Subject: [PATCH] print error in log if tcgetattr() fails instead of writing a empty file --- apt-pkg/deb/dpkgpm.cc | 7 ++++++- debian/changelog | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index fd1e6e085..0e468b590 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -423,7 +423,7 @@ bool pkgDPkgPM::RunScriptsWithPkgs(const char *Cnf) void pkgDPkgPM::DoStdin(int master) { unsigned char input_buf[256] = {0,}; - ssize_t len = read(0, input_buf, sizeof(input_buf)); + ssize_t len = read(STDIN_FILENO, input_buf, sizeof(input_buf)); if (len) FileFd::Write(master, input_buf, len); else @@ -1231,6 +1231,11 @@ bool pkgDPkgPM::Go(int OutStatusFd) tcsetattr(0, TCSAFLUSH, &rtt); sigprocmask(SIG_SETMASK, &original_sigmask, 0); } + } else { + const char *s = _("Can not write log, tcgetattr() failed for stdout"); + fprintf(stderr, "%s", s); + if(d->term_out) + fprintf(d->term_out, "%s",s); } // Fork dpkg pid_t Child; diff --git a/debian/changelog b/debian/changelog index 3b9a9bafd..f4f060065 100644 --- a/debian/changelog +++ b/debian/changelog @@ -7,6 +7,8 @@ apt (0.9.7.8) UNRELEASED; urgency=low * apt-pkg/deb/dpkgpm.cc: - use tcgetattr() on STDOUT instead of STDIN so that term.log works for redirected stdin + - print error in log if tcgetattr() fails instead of writing + a empty file -- Christian Perrier Mon, 24 Dec 2012 07:01:20 +0100 -- 2.45.2