From dbcc1983018e7684e53bbdec4bb59d93dd21c82f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dag-Erling=20Sm=C3=B8rgrav?= Date: Sun, 23 Sep 2001 22:03:39 +0000 Subject: Don't print running stats unless we're the foreground process. PR: 30764 --- usr.bin/fetch/fetch.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'usr.bin/fetch/fetch.c') diff --git a/usr.bin/fetch/fetch.c b/usr.bin/fetch/fetch.c index 5b321cd3c4f2..fc6ba2a0a93f 100644 --- a/usr.bin/fetch/fetch.c +++ b/usr.bin/fetch/fetch.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -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 */ -- cgit v1.2.3