|
Panu Matilainen |
e50e6c |
commit 771993d1fc6db95ae92ebe0200f7003554ea32da
|
|
Panu Matilainen |
e50e6c |
Author: Panu Matilainen <pmatilai@redhat.com>
|
|
Panu Matilainen |
e50e6c |
Date: Mon Feb 21 08:47:52 2011 +0200
|
|
Panu Matilainen |
e50e6c |
|
|
Panu Matilainen |
e50e6c |
Fix braindamage in the depgen helper collector loop (RhBug:675002)
|
|
Panu Matilainen |
e50e6c |
- Read any remaining data before exiting on SIGCHLD
|
|
Panu Matilainen |
e50e6c |
- Only perform one read() per loop, otherwise it could block
|
|
Panu Matilainen |
e50e6c |
- Handle EINTR while read()'ing
|
|
Panu Matilainen |
e50e6c |
|
|
Panu Matilainen |
e50e6c |
diff --git a/build/rpmfc.c b/build/rpmfc.c
|
|
Panu Matilainen |
e50e6c |
index 56bcb12..29334e2 100644
|
|
Panu Matilainen |
e50e6c |
--- a/build/rpmfc.c
|
|
Panu Matilainen |
e50e6c |
+++ b/build/rpmfc.c
|
|
Panu Matilainen |
e50e6c |
@@ -272,12 +272,6 @@ static StringBuf getOutputFrom(ARGV_t argv,
|
|
Panu Matilainen |
e50e6c |
break;
|
|
Panu Matilainen |
e50e6c |
}
|
|
Panu Matilainen |
e50e6c |
|
|
Panu Matilainen |
e50e6c |
- /* Child exited, we're done */
|
|
Panu Matilainen |
e50e6c |
- if (FD_ISSET(sigpipe, &ibits)) {
|
|
Panu Matilainen |
e50e6c |
- while (read(sigpipe, buf, sizeof(buf)) > 0) {};
|
|
Panu Matilainen |
e50e6c |
- break;
|
|
Panu Matilainen |
e50e6c |
- }
|
|
Panu Matilainen |
e50e6c |
-
|
|
Panu Matilainen |
e50e6c |
/* Write data to child */
|
|
Panu Matilainen |
e50e6c |
if (writeBytesLeft > 0 && FD_ISSET(toProg[1], &obits)) {
|
|
Panu Matilainen |
e50e6c |
size_t nb = (1024 < writeBytesLeft) ? 1024 : writeBytesLeft;
|
|
Panu Matilainen |
e50e6c |
@@ -293,11 +287,20 @@ static StringBuf getOutputFrom(ARGV_t argv,
|
|
Panu Matilainen |
e50e6c |
|
|
Panu Matilainen |
e50e6c |
/* Read when we get data back from the child */
|
|
Panu Matilainen |
e50e6c |
if (FD_ISSET(fromProg[0], &ibits)) {
|
|
Panu Matilainen |
e50e6c |
- int nbr;
|
|
Panu Matilainen |
e50e6c |
- while ((nbr = read(fromProg[0], buf, sizeof(buf)-1)) > 0) {
|
|
Panu Matilainen |
e50e6c |
- buf[nbr] = '\0';
|
|
Panu Matilainen |
e50e6c |
- appendStringBuf(readBuff, buf);
|
|
Panu Matilainen |
e50e6c |
+ int nbr = read(fromProg[0], buf, sizeof(buf)-1);
|
|
Panu Matilainen |
e50e6c |
+ if (nbr < 0 && errno == EINTR) continue;
|
|
Panu Matilainen |
e50e6c |
+ if (nbr < 0) {
|
|
Panu Matilainen |
e50e6c |
+ myerrno = errno;
|
|
Panu Matilainen |
e50e6c |
+ break;
|
|
Panu Matilainen |
e50e6c |
}
|
|
Panu Matilainen |
e50e6c |
+ buf[nbr] = '\0';
|
|
Panu Matilainen |
e50e6c |
+ appendStringBuf(readBuff, buf);
|
|
Panu Matilainen |
e50e6c |
+ }
|
|
Panu Matilainen |
e50e6c |
+
|
|
Panu Matilainen |
e50e6c |
+ /* Child exited, we're done */
|
|
Panu Matilainen |
e50e6c |
+ if (FD_ISSET(sigpipe, &ibits)) {
|
|
Panu Matilainen |
e50e6c |
+ while (read(sigpipe, buf, sizeof(buf)) > 0) {};
|
|
Panu Matilainen |
e50e6c |
+ break;
|
|
Panu Matilainen |
e50e6c |
}
|
|
Panu Matilainen |
e50e6c |
}
|
|
Panu Matilainen |
e50e6c |
|