From 84b62fd459ba7456b02533c8156ab480e6342b88 Mon Sep 17 00:00:00 2001 From: ewt Date: Wed, 14 Feb 1996 21:56:29 +0000 Subject: [PATCH] fixed to installArchive() 1) detect dead child correctly 2) handle all files when read() from pipe returns many of them CVS patchset: 274 CVS date: 1996/02/14 21:56:29 --- lib/install.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/install.c b/lib/install.c index f591e48..ad50761 100644 --- a/lib/install.c +++ b/lib/install.c @@ -326,6 +326,7 @@ static int installArchive(char * prefix, int fd, struct fileToInstall * files, char * chptr; char ** args; int len; + int childDead = 0; /* fd should be a gzipped cpio archive */ @@ -401,21 +402,26 @@ static int installArchive(char * prefix, int fd, struct fileToInstall * files, } do { + if (waitpid(child, &status, WNOHANG)) childDead = 1; + bytesRead = gzread(stream, buf, sizeof(buf)); if (write(p[1], buf, bytesRead) != bytesRead) { cpioFailed = 1; + childDead = 1; kill(SIGTERM, child); } if (needSecondPipe) { bytes = read(statusPipe[0], line, sizeof(line)); + while (bytes > 0) { fileInstalled.fileName = line; while ((chptr = (strchr(fileInstalled.fileName, '\n')))) { *chptr = '\0'; - message(MESS_DEBUG, "file \"%s\" complete\n", line); + message(MESS_DEBUG, "file \"%s\" complete\n", + fileInstalled.fileName); if (notify) { file = bsearch(&fileInstalled, files, fileCount, @@ -446,7 +452,7 @@ static int installArchive(char * prefix, int fd, struct fileToInstall * files, bytes = read(statusPipe[0], line, sizeof(line)); } } - } while (bytesRead); + } while (!childDead); gzclose(stream); close(p[1]); -- 2.7.4