aboutsummaryrefslogtreecommitdiffstats
path: root/parsehdlist.c
diff options
context:
space:
mode:
authorFrancois Pons <fpons@mandriva.com>2002-01-17 12:01:54 +0000
committerFrancois Pons <fpons@mandriva.com>2002-01-17 12:01:54 +0000
commit362a3293bf2f2da458dce726e1c4281533464784 (patch)
treebc6eab9070ca931bbeb36763995dcc8112a93af4 /parsehdlist.c
parent492b556e340f2722ad860950ed0245e5ea9335ba (diff)
downloadrpmtools-362a3293bf2f2da458dce726e1c4281533464784.tar
rpmtools-362a3293bf2f2da458dce726e1c4281533464784.tar.gz
rpmtools-362a3293bf2f2da458dce726e1c4281533464784.tar.bz2
rpmtools-362a3293bf2f2da458dce726e1c4281533464784.tar.xz
rpmtools-362a3293bf2f2da458dce726e1c4281533464784.zip
4.0-7mdk4.0.7
Diffstat (limited to 'parsehdlist.c')
-rw-r--r--parsehdlist.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/parsehdlist.c b/parsehdlist.c
index 16137eb..88c9235 100644
--- a/parsehdlist.c
+++ b/parsehdlist.c
@@ -1,7 +1,10 @@
+#include <sys/select.h>
+#include <sys/time.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/stat.h>
#include <fcntl.h>
+#include <unistd.h>
#include <signal.h>
#include <errno.h>
#include <rpm/rpmlib.h>
@@ -314,6 +317,15 @@ int main(int argc, char **argv)
int fdno[2];
if (!pipe(fdno)) {
if ((pid = fork()) != 0) {
+ fd_set readfds;
+ struct timeval timeout;
+
+ FD_ZERO(&readfds);
+ FD_SET(fdno[0], &readfds);
+ timeout.tv_sec = 1;
+ timeout.tv_usec = 0;
+ select(fdno[0]+1, &readfds, NULL, NULL, &timeout);
+
fd = fdDup(fdno[0]);
close(fdno[0]);
close(fdno[1]);
@@ -376,7 +388,17 @@ int main(int argc, char **argv)
long count = 0;
/* fprintf(stderr, "parsehdlist: reading %s\n", argv[i]); */
- while ((header=headerRead(fd, HEADER_MAGIC_YES))) {
+ while (count < 20 && (header=headerRead(fd, HEADER_MAGIC_YES)) == 0) {
+ struct timeval timeout;
+
+ timeout.tv_sec = 0;
+ timeout.tv_usec = 10000;
+ select(0, NULL, NULL, NULL, &timeout);
+
+ ++count;
+ }
+ count = 0;
+ while (header != 0) {
char *name = get_name(header, RPMTAG_NAME);
++count;
@@ -413,6 +435,7 @@ int main(int argc, char **argv)
}
headerFree(header);
}
+ header=headerRead(fd, HEADER_MAGIC_YES);
}
if (!count) exit(3); /* no package is an error */
}