Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 23 Sep 2001 14:38:32 -0400 (EDT)
From:      The Anarcat <anarcat@anarcat.dyndns.org>
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   bin/30764: PATCH: fetch(1) prints d/l status even if in background
Message-ID:  <20010923183832.B13B320B4A@shall.anarcat.dyndns.org>

next in thread | raw e-mail | index | archive | help

>Number:         30764
>Category:       bin
>Synopsis:       PATCH: fetch(1) prints d/l status even if in background
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Sep 23 11:40:01 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     The Anarcat
>Release:        FreeBSD 4.4-STABLE i386
>Organization:
Nada, Inc.
>Environment:
System: FreeBSD shall.anarcat.dyndns.org 4.4-STABLE FreeBSD 4.4-STABLE #7: Sat Sep 15 00:41:38 EDT 2001 anarcat@shall.anarcat.dyndns.org:/usr/obj/usr/src/sys/SHALL i386

>Description:

The fetch(1) utility (used mainly to fetch ports distfiles) features a
display of the current progress of the download. 

When you put fetch(1) in background, it keeps on clobbering the terminal
with that status, which is really annoying. ftp(1) on the other hand,
gracefully checks if it's the foreground process before doing that.

Some might consider this a feature, I call it a bug. :)

>How-To-Repeat:

$ fetch ftp://ftp11.freebsd.org/pub/FreeBSD/ports/packages/Latest/samba.tgz &

>Fix:

I stole the code from ftp(1), so there should be any problems...

--- /usr/src/usr.bin/fetch/fetch.c	Tue Aug 21 13:15:38 2001
+++ fetch.c	Sun Sep 23 14:36:58 2001
@@ -42,6 +42,8 @@
 #include <sysexits.h>
 #include <unistd.h>
 
+#include <sys/ioctl.h>
+
 #include <fetch.h>
 
 #define MINBUFSIZE	4096
@@ -117,6 +119,19 @@
 {
     struct timeval now;
     
+    static pid_t pgrp = -1;
+    int ctty_pgrp;
+
+    if (pgrp == -1)
+            pgrp = getpgrp();
+
+    /*
+     * do not print display (ie return) if we're not foreground process
+     */
+    if (ioctl(STDOUT_FILENO, TIOCGPGRP, &ctty_pgrp) == -1 ||
+        ctty_pgrp != (int)pgrp)
+        return;
+
     if (!v_tty || !v_level)
 	return;
     
This works well here.
>Release-Note:
>Audit-Trail:
>Unformatted:

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010923183832.B13B320B4A>