From: Panu Matilainen Date: Wed, 8 Jun 2011 07:01:14 +0000 (+0300) Subject: Abort depgen output reading on EOF, not child exiting X-Git-Tag: tznext/4.11.0.1.tizen20130304~1037 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fb3412e80b52b19d51557b81b318b85f785acffd;p=tools%2Flibrpm-tizen.git 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. --- 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; } }