summaryrefslogtreecommitdiff
path: root/apt-pkg/deb/dpkgpm.cc
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2015-03-09 01:34:10 +0100
committerDavid Kalnischkies <david@kalnischkies.de>2015-03-16 17:59:31 +0100
commitd61960d9244340956a27f4ca46aecd15cc75e18b (patch)
treec8f7cb33e08c84bcf06fbff39647dc03bc103afb /apt-pkg/deb/dpkgpm.cc
parentb0be0e09cfbbcb033eb0b92eaf17ac31a6b9f423 (diff)
parent1a0619ac765cc0b2f4906c96c1a4d7f510569a3f (diff)
merge debian/sid into debian/experimental
Diffstat (limited to 'apt-pkg/deb/dpkgpm.cc')
-rw-r--r--apt-pkg/deb/dpkgpm.cc16
1 files changed, 12 insertions, 4 deletions
diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc
index 8a8214c19..09bd9149f 100644
--- a/apt-pkg/deb/dpkgpm.cc
+++ b/apt-pkg/deb/dpkgpm.cc
@@ -73,7 +73,8 @@ public:
pkgDPkgPMPrivate() : stdin_is_dev_null(false), dpkgbuf_pos(0),
term_out(NULL), history_out(NULL),
progress(NULL), tt_is_valid(false), master(-1),
- slave(NULL), protect_slave_from_dying(-1)
+ slave(NULL), protect_slave_from_dying(-1),
+ direct_stdin(false)
{
dpkgbuf[0] = '\0';
}
@@ -100,6 +101,7 @@ public:
sigset_t sigmask;
sigset_t original_sigmask;
+ bool direct_stdin;
};
namespace
@@ -1069,6 +1071,9 @@ void pkgDPkgPM::StartPtyMagic()
return;
}
+ if (isatty(STDIN_FILENO) == 0)
+ d->direct_stdin = true;
+
_error->PushToStack();
d->master = posix_openpt(O_RDWR | O_NOCTTY);
@@ -1166,7 +1171,10 @@ void pkgDPkgPM::SetupSlavePtyMagic()
_error->FatalE("ioctl", "Setting TIOCSCTTY for slave fd %d failed!", slaveFd);
else
{
- for (unsigned short i = 0; i < 3; ++i)
+ unsigned short i = 0;
+ if (d->direct_stdin == true)
+ ++i;
+ for (; i < 3; ++i)
if (dup2(slaveFd, i) == -1)
_error->FatalE("dup2", "Dupping %d to %d in child failed!", slaveFd, i);
@@ -1582,8 +1590,8 @@ bool pkgDPkgPM::Go(APT::Progress::PackageManager *progress)
// wait for input or output here
FD_ZERO(&rfds);
- if (d->master >= 0 && !d->stdin_is_dev_null)
- FD_SET(0, &rfds);
+ if (d->master >= 0 && d->direct_stdin == false && d->stdin_is_dev_null == false)
+ FD_SET(STDIN_FILENO, &rfds);
FD_SET(_dpkgin, &rfds);
if(d->master >= 0)
FD_SET(d->master, &rfds);