Subject: bin/3735: patch for ftp to print progress bar only if foreground.
To: None <gnats-bugs@gnats.netbsd.org>
From: None <enami@ba2.so-net.or.jp>
List: netbsd-bugs
Date: 06/10/1997 21:42:00
>Number:         3735
>Category:       bin
>Synopsis:       patch for ftp to print progress bar only if foreground.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Tue Jun 10 07:05:01 1997
>Last-Modified:
>Originator:     enami tsugutomo
>Organization:
>Release:        NetBSD-current 1997 June 07
>Environment:
System: NetBSD pavlov.enami.ba2.so-net.or.jp 1.2F NetBSD 1.2F (PAVLOV) #282: Sun Jun 8 16:48:33 JST 1997 enami@pavlov.enami.ba2.so-net.or.jp:/b/netbsd/kernel/compile/PAVLOV i386


>Description:
	Progress bar of ftp command is useful, but even if the process
	is gone to background during transfer, it continues print it.
	I think it is better print progress bar only if ftp process is
	foreground.

>How-To-Repeat:
	Do ftp with progress bar, and suspend it and make it background.
	The ftp process still prints progress bar.

>Fix:
	Here is my fix:

cvs diff: Diffing .
Index: util.c
===================================================================
RCS file: /a/cvsroot/NetBSD/src/usr.bin/ftp/util.c,v
retrieving revision 1.1.1.7
diff -u -r1.1.1.7 util.c
--- util.c	1997/05/12 16:30:58	1.1.1.7
+++ util.c	1997/06/10 12:09:42
@@ -497,8 +497,18 @@
 void
 updateprogressmeter()
 {
+	static pid_t pgrp = -1;
+	int ctty_pgrp;
 
-	progressmeter(0);
+	if (pgrp == -1)
+		pgrp = getpgrp();
+
+	/*
+	 * print progress bar only if we are foreground process.
+	 */
+	if (ioctl(STDOUT_FILENO, TIOCGPGRP, &ctty_pgrp) != -1 &&
+	    ctty_pgrp == pgrp)
+		progressmeter(0);
 }
 
 /*
>Audit-Trail:
>Unformatted: