--- file-4.13.orig/src/compress.c 2005-01-07 22:17:26 +0300 +++ file-4.13/src/compress.c 2005-02-12 18:02:16 +0300 @@ -314,6 +314,7 @@ uncompressbuf(struct magic_set *ms, int const unsigned char *old, unsigned char **newch, size_t n) { int fdin[2], fdout[2]; + pid_t pid1 = -1, pid2 = -1; int r; #ifdef HAVE_LIBZ @@ -327,7 +328,7 @@ uncompressbuf(struct magic_set *ms, int file_error(ms, errno, "cannot create pipe"); return 0; } - switch (fork()) { + switch ((pid1=fork())) { case 0: /* child */ (void) close(0); if (fd != -1) { @@ -368,7 +369,7 @@ uncompressbuf(struct magic_set *ms, int * 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) { @@ -423,12 +424,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; } }