From fb3412e80b52b19d51557b81b318b85f785acffd Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Wed, 8 Jun 2011 10:01:14 +0300 Subject: [PATCH] Abort depgen output reading on EOF, not child exiting - There could, at least in theory, still be data to read after we receive SIGCHLD. Stop the loop on EOF on read instead. Thanks to Michael Schroeder for pointing this out. --- build/rpmfc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/rpmfc.c b/build/rpmfc.c index a01cba2..70eebc3 100644 --- a/build/rpmfc.c +++ b/build/rpmfc.c @@ -320,6 +320,7 @@ static StringBuf getOutputFrom(ARGV_t argv, /* Read when we get data back from the child */ if (FD_ISSET(fromProg[0], &ibits)) { int nbr = read(fromProg[0], buf, sizeof(buf)-1); + if (nbr == 0) break; /* EOF, we're done */ if (nbr < 0 && errno == EINTR) continue; if (nbr < 0) { myerrno = errno; @@ -329,10 +330,9 @@ static StringBuf getOutputFrom(ARGV_t argv, appendStringBuf(readBuff, buf); } - /* Child exited, we're done */ + /* Child exited */ if (FD_ISSET(sigpipe, &ibits)) { while (read(sigpipe, buf, sizeof(buf)) > 0) {}; - break; } } -- 2.7.4