diff options
author | Michael Vogt <michael.vogt@ubuntu.com> | 2008-11-24 10:44:46 +0100 |
---|---|---|
committer | Michael Vogt <michael.vogt@ubuntu.com> | 2008-11-24 10:44:46 +0100 |
commit | 07dd557b6fd80ce2df235f1697189b6a8f190ff4 (patch) | |
tree | e1f3548a8f329422b31a6780a68fa0476ae71bb1 /apt-pkg/deb | |
parent | 1631453861ac907938a084f3070a274c281d852a (diff) |
* apt-pkg/deb/dpkgpm.cc:
- fix potential hang when in a backgroud process group
Diffstat (limited to 'apt-pkg/deb')
-rw-r--r-- | apt-pkg/deb/dpkgpm.cc | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index 2e9dedefa..a88e23081 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -563,6 +563,11 @@ static int racy_pselect(int nfds, fd_set *readfds, fd_set *writefds, */ bool pkgDPkgPM::Go(int OutStatusFd) { + fd_set rfds; + struct timespec tv; + sigset_t sigmask; + sigset_t original_sigmask; + unsigned int MaxArgs = _config->FindI("Dpkg::MaxArgs",8*1024); unsigned int MaxArgBytes = _config->FindI("Dpkg::MaxArgBytes",32*1024); bool NoTriggers = _config->FindB("DPkg::NoTriggers",false); @@ -777,7 +782,14 @@ bool pkgDPkgPM::Go(int OutStatusFd) rtt = tt; cfmakeraw(&rtt); rtt.c_lflag &= ~ECHO; + // block SIGTTOU during tcsetattr to prevent a hang if + // the process is a member of the background process group + // http://www.opengroup.org/onlinepubs/000095399/functions/tcsetattr.html + sigemptyset(&sigmask); + sigaddset(&sigmask, SIGTTOU); + sigprocmask(SIG_BLOCK,&sigmask, &original_sigmask); tcsetattr(0, TCSAFLUSH, &rtt); + sigprocmask(SIG_SETMASK, &original_sigmask, 0); } // Fork dpkg @@ -844,10 +856,6 @@ bool pkgDPkgPM::Go(int OutStatusFd) close(slave); // setups fds - fd_set rfds; - struct timespec tv; - sigset_t sigmask; - sigset_t original_sigmask; sigemptyset(&sigmask); sigprocmask(SIG_BLOCK,&sigmask,&original_sigmask); |