diff options
author | ross <ross@NetBSD.org> | 2003-02-12 00:58:34 +0000 |
---|---|---|
committer | ross <ross@NetBSD.org> | 2003-02-12 00:58:34 +0000 |
commit | 0c9ec8b0c3e49e562c5d84b59ed21592148103cd (patch) | |
tree | 7d738782f486d0c676898c5fe54dcd3e93900a9a | |
parent | 5c96e0f396329d75e901cd74db554a49bedfc0b2 (diff) | |
download | bsd-progress-0c9ec8b0c3e49e562c5d84b59ed21592148103cd.tar.gz bsd-progress-0c9ec8b0c3e49e562c5d84b59ed21592148103cd.tar.zst bsd-progress-0c9ec8b0c3e49e562c5d84b59ed21592148103cd.zip |
Sigh, use an even more elaborate wait loop; it turns out we have a child
before we even start when run from sysinst. Thanks also Takao Shinohara.
-rw-r--r-- | progress.c | 24 |
1 files changed, 18 insertions, 6 deletions
@@ -1,4 +1,4 @@ -/* $NetBSD: progress.c,v 1.6 2003/02/10 09:10:01 ross Exp $ */ +/* $NetBSD: progress.c,v 1.7 2003/02/12 00:58:34 ross Exp $ */ /*- * Copyright (c) 2003 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: progress.c,v 1.6 2003/02/10 09:10:01 ross Exp $"); +__RCSID("$NetBSD: progress.c,v 1.7 2003/02/12 00:58:34 ross Exp $"); #endif /* not lint */ #include <sys/types.h> @@ -84,7 +84,7 @@ main(int argc, char *argv[]) { static char fb_buf[BUFSIZ]; char *infile = NULL; - pid_t pid; + pid_t pid = 0, gzippid = 0; int ch, fd, outpipe[2], waitstat; int lflag = 0, zflag = 0; ssize_t nr, nw, off; @@ -152,7 +152,6 @@ main(int argc, char *argv[]) } /* Pipe input through gzip -dc if -z is given */ if (zflag) { - pid_t gzippid; int gzippipe[2]; if (pipe(gzippipe) < 0) @@ -211,8 +210,21 @@ main(int argc, char *argv[]) (unsigned) nr); close(outpipe[1]); - while(wait(&waitstat) != -1) - continue; + while (pid || gzippid) { + int deadpid; + + deadpid = wait(&waitstat); + + if (deadpid == pid) + pid = 0; + else if (deadpid == gzippid) + gzippid = 0; + else if (deadpid != -1) + continue; + else if (errno == EINTR) + continue; + else break; + } progressmeter(1); return 0; |