]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/deb/dpkgpm.cc
add missing changelog entry
[apt.git] / apt-pkg / deb / dpkgpm.cc
index ce4d4b44ba0dddbce6019d09630fb0a79dab7c1d..11bf827d7082e7255eae313f14cf6dc90584a4fe 100644 (file)
@@ -342,9 +342,12 @@ bool pkgDPkgPM::RunScriptsWithPkgs(const char *Cnf)
 */
 void pkgDPkgPM::DoStdin(int master)
 {
-   char input_buf[256] = {0,}; 
-   int len = read(0, input_buf, sizeof(input_buf));
-   write(master, input_buf, len);
+   unsigned char input_buf[256] = {0,}; 
+   ssize_t len = read(0, input_buf, sizeof(input_buf));
+   if (len)
+      write(master, input_buf, len);
+   else
+      stdin_is_dev_null = true;
 }
                                                                        /*}}}*/
 // DPkgPM::DoTerminalPty - Read the terminal pty and write log         /*{{{*/
@@ -354,9 +357,9 @@ void pkgDPkgPM::DoStdin(int master)
  */
 void pkgDPkgPM::DoTerminalPty(int master)
 {
-   char term_buf[1024] = {0,};
+   unsigned char term_buf[1024] = {0,0, };
 
-   int len=read(master, term_buf, sizeof(term_buf));
+   ssize_t len=read(master, term_buf, sizeof(term_buf));
    if(len == -1 && errno == EIO)
    {
       // this happens when the child is about to exit, we
@@ -543,6 +546,27 @@ bool pkgDPkgPM::CloseLog()
    return true;
 }
 
+/*{{{*/
+// This implements a racy version of pselect for those architectures
+// that don't have a working implementation.
+// FIXME: Probably can be removed on Lenny+1
+static int racy_pselect(int nfds, fd_set *readfds, fd_set *writefds,
+   fd_set *exceptfds, const struct timespec *timeout,
+   const sigset_t *sigmask)
+{
+   sigset_t origmask;
+   struct timeval tv;
+   int retval;
+
+   tv.tv_sec = timeout->tv_sec;
+   tv.tv_usec = timeout->tv_nsec/1000;
+
+   sigprocmask(SIG_SETMASK, sigmask, &origmask);
+   retval = select(nfds, readfds, writefds, exceptfds, &tv);
+   sigprocmask(SIG_SETMASK, &origmask, 0);
+   return retval;
+}
+/*}}}*/
 
 // DPkgPM::Go - Run the sequence                                       /*{{{*/
 // ---------------------------------------------------------------------
@@ -618,6 +642,8 @@ bool pkgDPkgPM::Go(int OutStatusFd)
       }
    }   
 
+   stdin_is_dev_null = false;
+
    // create log
    OpenLog();
 
@@ -847,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);
@@ -855,6 +882,9 @@ bool pkgDPkgPM::Go(int OutStatusFd)
         tv.tv_nsec = 0;
         select_ret = pselect(max(master, _dpkgin)+1, &rfds, NULL, NULL, 
                              &tv, &original_sigmask);
+        if (select_ret < 0 && (errno == EINVAL || errno == ENOSYS))
+           select_ret = racy_pselect(max(master, _dpkgin)+1, &rfds, NULL,
+                                     NULL, &tv, &original_sigmask);
         if (select_ret == 0) 
            continue;
         else if (select_ret < 0 && errno == EINTR)