* Applied patch from Aurelien Jarno <aurel32@debian.org> to avoid CPU
authorOtavio Salvador <otavio@ossystems.com.br>
Mon, 26 Nov 2007 17:44:46 +0000 (15:44 -0200)
committerOtavio Salvador <otavio@ossystems.com.br>
Mon, 26 Nov 2007 17:44:46 +0000 (15:44 -0200)
  getting crazy when /dev/null is redirected to stdin (which breaks
  buildds), closes: #452858.

apt-pkg/deb/dpkgpm.cc
apt-pkg/deb/dpkgpm.h
debian/changelog

index 5a7711a..d796146 100644 (file)
@@ -344,7 +344,10 @@ void pkgDPkgPM::DoStdin(int master)
 {
    char input_buf[256] = {0,}; 
    int len = read(0, input_buf, sizeof(input_buf));
-   write(master, input_buf, len);
+   if (len)
+      write(master, input_buf, len);
+   else
+      stdin_is_dev_null = true;
 }
                                                                        /*}}}*/
 // DPkgPM::DoTerminalPty - Read the terminal pty and write log         /*{{{*/
@@ -639,6 +642,8 @@ bool pkgDPkgPM::Go(int OutStatusFd)
       }
    }   
 
+   stdin_is_dev_null = false;
+
    // create log
    OpenLog();
 
@@ -868,7 +873,8 @@ bool pkgDPkgPM::Go(int OutStatusFd)
 
         // wait for input or output here
         FD_ZERO(&rfds);
-        FD_SET(0, &rfds); 
+        if (!stdin_is_dev_null)
+           FD_SET(0, &rfds); 
         FD_SET(_dpkgin, &rfds);
         if(master >= 0)
            FD_SET(master, &rfds);
index b7f45b9..81a888f 100644 (file)
@@ -23,6 +23,8 @@ class pkgDPkgPM : public pkgPackageManager
 {
    private:
 
+   bool stdin_is_dev_null;
+
    // the buffer we use for the dpkg status-fd reading
    char dpkgbuf[1024];
    int dpkgbuf_pos;
index ad860db..f5f9659 100644 (file)
@@ -4,8 +4,11 @@ apt (0.7.10) UNRELEASED; urgency=low
     apt-mark, closes: #430207.
   * Applied patch from Andrei Popescu <andreimpopescu@gmail.com> to add a
     note about some frontends in apt.8 manpage, closes: #438545.
+  * Applied patch from Aurelien Jarno <aurel32@debian.org> to avoid CPU
+    getting crazy when /dev/null is redirected to stdin (which breaks
+    buildds), closes: #452858.
 
- -- Otavio Salvador <otavio@ossystems.com.br>  Mon, 19 Nov 2007 17:52:34 -0200
+ -- Otavio Salvador <otavio@ossystems.com.br>  Mon, 26 Nov 2007 15:42:43 -0200
 
 apt (0.7.9) unstable; urgency=low