diff options
author | jbj <devnull@localhost> | 2005-01-03 14:28:50 +0000 |
---|---|---|
committer | jbj <devnull@localhost> | 2005-01-03 14:28:50 +0000 |
commit | 34caf4357ac173eb273ec16611dc8da24fa75858 (patch) | |
tree | 79fcd0ba25688189c5bd551c58b786873c026916 /file | |
parent | f7348895a66e7e03b126bef8e3857bf4c89358d5 (diff) | |
download | librpm-tizen-34caf4357ac173eb273ec16611dc8da24fa75858.tar.gz librpm-tizen-34caf4357ac173eb273ec16611dc8da24fa75858.tar.bz2 librpm-tizen-34caf4357ac173eb273ec16611dc8da24fa75858.zip |
Wait for specific pid's.
CVS patchset: 7664
CVS date: 2005/01/03 14:28:50
Diffstat (limited to 'file')
-rw-r--r-- | file/src/compress.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/file/src/compress.c b/file/src/compress.c index b0236f46f..06e8ae7ef 100644 --- a/file/src/compress.c +++ b/file/src/compress.c @@ -324,7 +324,8 @@ uncompressbuf(struct magic_set *ms, size_t method, const unsigned char *old, { int fdin[2], fdout[2]; int r; - + pid_t pid1, pid2; + /* The buffer is NUL terminated, and we don't need that. */ n--; @@ -337,7 +338,7 @@ uncompressbuf(struct magic_set *ms, size_t method, const unsigned char *old, file_error(ms, errno, "cannot create pipe"); return 0; } - switch (fork()) { + switch ((pid1=fork())) { case 0: /* child */ (void) close(0); (void) dup(fdin[0]); @@ -363,7 +364,7 @@ uncompressbuf(struct magic_set *ms, size_t method, const unsigned char *old, (void) close(fdin[0]); (void) close(fdout[1]); /* fork again, to avoid blocking because both pipes filled */ - switch (fork()) { + switch ((pid2=fork())) { case 0: /* child */ (void)close(fdout[0]); if (swrite(fdin[1], old, n) != n) @@ -398,12 +399,8 @@ err: if (fdin[1] != -1) (void) close(fdin[1]); (void) close(fdout[0]); -#ifdef WNOHANG - while (waitpid(-1, NULL, WNOHANG) != -1) - continue; -#else - (void)wait(NULL); -#endif + waitpid(pid1, NULL, 0); + waitpid(pid2, NULL, 0); return n; } /*@notreached@*/ |