From owner-freebsd-bugs Sun Sep 23 11:40: 8 2001 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 086FC37B420 for ; Sun, 23 Sep 2001 11:40:02 -0700 (PDT) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.4/8.11.4) id f8NIe2o84746; Sun, 23 Sep 2001 11:40:02 -0700 (PDT) (envelope-from gnats) Received: from tomts19-srv.bellnexxia.net (tomts19.bellnexxia.net [209.226.175.73]) by hub.freebsd.org (Postfix) with ESMTP id 14A3237B409 for ; Sun, 23 Sep 2001 11:38:59 -0700 (PDT) Received: from khan.anarcat.dyndns.org ([65.92.169.79]) by tomts19-srv.bellnexxia.net (InterMail vM.4.01.03.16 201-229-121-116-20010115) with ESMTP id <20010923183843.RLMJ3504.tomts19-srv.bellnexxia.net@khan.anarcat.dyndns.org> for ; Sun, 23 Sep 2001 14:38:43 -0400 Received: from shall.anarcat.dyndns.org (shall.anarcat.dyndns.org [192.168.0.1]) by khan.anarcat.dyndns.org (Postfix) with ESMTP id B0B971A7C for ; Sun, 23 Sep 2001 14:38:38 -0400 (EDT) Received: by shall.anarcat.dyndns.org (Postfix, from userid 1000) id B13B320B4A; Sun, 23 Sep 2001 14:38:32 -0400 (EDT) Message-Id: <20010923183832.B13B320B4A@shall.anarcat.dyndns.org> Date: Sun, 23 Sep 2001 14:38:32 -0400 (EDT) From: The Anarcat Reply-To: The Anarcat To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.113 Subject: bin/30764: PATCH: fetch(1) prints d/l status even if in background Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >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 #include +#include + #include #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