summaryrefslogtreecommitdiff
path: root/apt-pkg/deb
diff options
context:
space:
mode:
authorMichael Vogt <mvo@debian.org>2014-01-25 21:54:52 +0100
committerMichael Vogt <mvo@debian.org>2014-01-25 21:54:52 +0100
commit62dcafb391a940534d5fb3b804dc461b1187d706 (patch)
tree83d28ffd4b0af97a0bba4f59c9a44e18091186b6 /apt-pkg/deb
parente093518c03b49a2def83d8b680be4490fed6e69c (diff)
parent8c39c4b6e65036390b8ca4d74174192739a4139d (diff)
Merge branch 'debian/experimental-no-abi-break' into debian/sid
Diffstat (limited to 'apt-pkg/deb')
-rw-r--r--apt-pkg/deb/dpkgpm.cc28
1 files changed, 19 insertions, 9 deletions
diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc
index 14ce133cf..506ebf620 100644
--- a/apt-pkg/deb/dpkgpm.cc
+++ b/apt-pkg/deb/dpkgpm.cc
@@ -1028,6 +1028,12 @@ bool pkgDPkgPM::Go(int StatusFd)
void pkgDPkgPM::StartPtyMagic()
{
+ if (_config->FindB("Dpkg::Use-Pty", true) == false)
+ {
+ d->master = d->slave = -1;
+ return;
+ }
+
// setup the pty and stuff
struct winsize win;
@@ -1036,10 +1042,9 @@ void pkgDPkgPM::StartPtyMagic()
_error->PushToStack();
if (tcgetattr(STDOUT_FILENO, &d->tt) == 0)
{
- ioctl(1, TIOCGWINSZ, (char *)&win);
- if (_config->FindB("Dpkg::Use-Pty", true) == false)
+ if (ioctl(1, TIOCGWINSZ, (char *)&win) < 0)
{
- d->master = d->slave = -1;
+ _error->Errno("ioctl", _("ioctl(TIOCGWINSZ) failed"));
} else if (openpty(&d->master, &d->slave, NULL, &d->tt, &win) < 0)
{
_error->Errno("openpty", _("Can not write log (%s)"), _("Is /dev/pts mounted?"));
@@ -1393,12 +1398,17 @@ bool pkgDPkgPM::GoNoABIBreak(APT::Progress::PackageManager *progress)
if(d->slave >= 0 && d->master >= 0)
{
setsid();
- ioctl(d->slave, TIOCSCTTY, 0);
- close(d->master);
- dup2(d->slave, 0);
- dup2(d->slave, 1);
- dup2(d->slave, 2);
- close(d->slave);
+ int res = ioctl(d->slave, TIOCSCTTY, 0);
+ if (res < 0) {
+ std::cerr << "ioctl(TIOCSCTTY) failed for fd: "
+ << d->slave << std::endl;
+ } else {
+ close(d->master);
+ dup2(d->slave, 0);
+ dup2(d->slave, 1);
+ dup2(d->slave, 2);
+ close(d->slave);
+ }
}
close(fd[0]); // close the read end of the pipe