--- debianutils-1.14/run-parts.c.org	2005-03-22 21:46:21.000000000 +0300
+++ debianutils-1.14/run-parts.c	2005-03-22 22:00:27.000000000 +0300
@@ -125,32 +125,6 @@ int valid_name (const struct dirent *d)
 }
 
 
-void set_fl (int fd, int flags)
-{
-  int val;
-  if ((val = fcntl(fd, F_GETFL, 0)) < 0) {
-    error("fcntl F_GETFL: %s", strerror(errno));
-    exit(1);
-  }
-  val |= flags;
-  if (fcntl(fd, F_SETFL, val) < 0) {
-    error("fcntl F_SETFL: %s", strerror(errno));
-    exit(1);
-  }
-}
-
-
-/* We have to abort the select() call in run_part when we receive a
- * SIGCHLD signal. We can't simply ignore it, so we do nothing.
- */
-
-/* itz Tue Nov 26 13:23:27 PST 2002 why "We have to abort?"
-   just leave the default and reap child at the end
- */
-void catch_sigchld(int sig) {
-}
-
-
 /* Execute a file */
 void run_part (char *progname)
 {
@@ -186,30 +160,23 @@ void run_part (char *progname)
 
   if (report_mode) {
     fd_set set;
-    int max, r, w, printflag;
+    int max, r, printflag;
     ssize_t c;
     char buf[4096];
     
     close(pout[1]);
     close(perr[1]);
-    /* itz Tue Nov 26 13:26:09 PST 2002 why is this necessary? */
-    /*     set_fl(pout[0], O_NONBLOCK); */
-    /*     set_fl(perr[0], O_NONBLOCK); */
     max = pout[0] > perr[0] ? pout[0]+1 : perr[0]+1;
     printflag = 0;
     
     while (pout[0] >= 0 || perr[0] >= 0) {
 
-      FD_ZERO(&set);
-      if (pout[0] >= 0) FD_SET(pout[0], &set);
-      if (perr[0] >= 0) FD_SET(perr[0], &set);
-      r = select(max, &set, 0, 0, 0);
-      while (r < 0 && errno == EINTR) {
+      do  {
         FD_ZERO(&set);
         if (pout[0] >= 0) FD_SET(pout[0], &set);
         if (perr[0] >= 0) FD_SET(perr[0], &set);
         r = select(max, &set, 0, 0, 0);
-      } /*while*/        
+      } while (r < 0 && errno == EINTR);
       
       if (r < 0) {
         /* assert(errno != EINTR) */
@@ -230,6 +197,11 @@ void run_part (char *progname)
 	    close(pout[0]);
 	    pout[0] = -1;
 	  }
+	  else if (c < 0) {
+	    close(pout[0]);
+	    pout[0] = -1;
+	    error("failed to read from stdout pipe: %s", strerror (errno)); 
+	  }
 	}
 	if (perr[0] >= 0 && FD_ISSET(perr[0], &set)) {
 	  c = read(perr[0], buf, sizeof(buf));
@@ -245,6 +217,11 @@ void run_part (char *progname)
 	    close(perr[0]);
 	    perr[0] = -1;
 	  }
+	  else if (c < 0) {
+	    close(perr[0]);
+	    perr[0] = -1;
+	    error("failed to read from error pipe: %s", strerror (errno)); 
+	  }
 	}
       } else {
         /* assert(FALSE): select was called with infinite timeout, so
