eliminate redundant close in provide/require processing.
authorjbj <devnull@localhost>
Thu, 10 Sep 1998 15:09:21 +0000 (15:09 +0000)
committerjbj <devnull@localhost>
Thu, 10 Sep 1998 15:09:21 +0000 (15:09 +0000)
CVS patchset: 2286
CVS date: 1998/09/10 15:09:21

CHANGES
build/files.c

diff --git a/CHANGES b/CHANGES
index 3ff3b20..bafba90 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -16,6 +16,7 @@
        - create /usr/lib/rpm directory and move rpmrc et al there
 
 2.5.3 -> 2.5.4:
+       - eliminate redundant close in provide/require processing.
        - solaris portability patch resurrection (Steve Sanberg).
        - add %license/%readme virtual file attributes
         - align "Build Host:" with other fields
index 39bec04..131ee84 100644 (file)
@@ -1431,7 +1431,6 @@ static StringBuf getOutputFrom(char *dir, char *argv[],
                        int failNonZero)
 {
     int progPID;
-    int progDead;
     int toProg[2];
     int fromProg[2];
     int status;
@@ -1478,12 +1477,7 @@ static StringBuf getOutputFrom(char *dir, char *argv[],
     
     readBuff = newStringBuf();
 
-    progDead = 0;
     do {
-       if (waitpid(progPID, &status, WNOHANG)) {
-           progDead = 1;
-       }
-
        /* Write some stuff to the process if possible */
         if (writeBytesLeft) {
            if ((bytesWritten =
@@ -1497,22 +1491,22 @@ static StringBuf getOutputFrom(char *dir, char *argv[],
            }
            writeBytesLeft -= bytesWritten;
            writePtr += bytesWritten;
-       } else {
+       } else if (toProg[1] >= 0) {
            close(toProg[1]);
+           toProg[1] = -1;
        }
        
        /* Read any data from prog */
-       bytes = read(fromProg[0], buf, sizeof(buf)-1);
-       while (bytes > 0) {
+       while ((bytes = read(fromProg[0], buf, sizeof(buf)-1)) > 0) {
            buf[bytes] = '\0';
            appendStringBuf(readBuff, buf);
-           bytes = read(fromProg[0], buf, sizeof(buf)-1);
        }
 
        /* terminate when prog dies */
-    } while (!progDead);
+    } while (!waitpid(progPID, &status, WNOHANG));
 
-    close(toProg[1]);
+    if (toProg[1] >= 0)
+       close(toProg[1]);
     close(fromProg[0]);
     signal(SIGPIPE, oldhandler);