diff options
author | des <des@FreeBSD.org> | 2001-09-23 22:03:39 +0000 |
---|---|---|
committer | des <des@FreeBSD.org> | 2001-09-23 22:03:39 +0000 |
commit | 3274d63b58830e318cb5bacbd61d1cebd8a80ca4 (patch) | |
tree | 95b17091fcfdf8d7d8dc64dba56df752fdd0466c /usr.bin/fetch/fetch.c | |
parent | 74ff6b8f7e014aa3bc9072d379cce3edc7e34e79 (diff) | |
download | FreeBSD-src-3274d63b58830e318cb5bacbd61d1cebd8a80ca4.zip FreeBSD-src-3274d63b58830e318cb5bacbd61d1cebd8a80ca4.tar.gz |
Don't print running stats unless we're the foreground process.
PR: 30764
Diffstat (limited to 'usr.bin/fetch/fetch.c')
-rw-r--r-- | usr.bin/fetch/fetch.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/usr.bin/fetch/fetch.c b/usr.bin/fetch/fetch.c index 5b321cd..fc6ba2a 100644 --- a/usr.bin/fetch/fetch.c +++ b/usr.bin/fetch/fetch.c @@ -31,6 +31,7 @@ #include <sys/param.h> #include <sys/stat.h> #include <sys/socket.h> +#include <sys/ioctl.h> #include <ctype.h> #include <err.h> @@ -75,6 +76,7 @@ int t_flag; /*! -t: workaround TCP bug */ int U_flag; /* -U: do not use high ports */ int v_level = 1; /* -v: verbosity level */ int v_tty; /* stdout is a tty */ +pid_t pgrp; /* our process group */ u_int w_secs; /* -w: retry delay */ int family = PF_UNSPEC; /* -[46]: address family to use */ @@ -123,10 +125,16 @@ static void stat_display(struct xferstat *xs, int force) { struct timeval now; + int ctty_pgrp; if (!v_tty || !v_level) return; + /* check if we're the foreground process */ + if (ioctl(STDERR_FILENO, TIOCGPGRP, &ctty_pgrp) == -1 || + (pid_t)ctty_pgrp != pgrp) + return; + gettimeofday(&now, NULL); if (!force && now.tv_sec <= xs->last.tv_sec) return; @@ -827,6 +835,9 @@ main(int argc, char *argv[]) /* check if output is to a tty (for progress report) */ v_tty = isatty(STDERR_FILENO); + if (v_tty) + pgrp = getpgrp(); + r = 0; /* authentication */ |