From owner-freebsd-bugs@FreeBSD.ORG Wed Jan 16 07:50:05 2008 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 126CC16A418 for ; Wed, 16 Jan 2008 07:50:05 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id E9CDC13C465 for ; Wed, 16 Jan 2008 07:50:04 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.2/8.14.2) with ESMTP id m0G7o474093632 for ; Wed, 16 Jan 2008 07:50:04 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.2/8.14.1/Submit) id m0G7o4an093631; Wed, 16 Jan 2008 07:50:04 GMT (envelope-from gnats) Date: Wed, 16 Jan 2008 07:50:04 GMT Message-Id: <200801160750.m0G7o4an093631@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: Giorgos Keramidas Cc: Subject: Re: bin/119705: [PATCH] make iostat a bit smarter about the number of tty rows X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Giorgos Keramidas List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Jan 2008 07:50:05 -0000 The following reply was made to PR bin/119705; it has been noted by GNATS. From: Giorgos Keramidas To: Maxim Konovalov Cc: Bruce Evans , bug-followup@freebsd.org Subject: Re: bin/119705: [PATCH] make iostat a bit smarter about the number of tty rows Date: Wed, 16 Jan 2008 09:41:38 +0200 On 2008-01-16 09:39, Giorgos Keramidas wrote: > Both fixed, I think. The new version of the patch is attached below, > after the following changes: > > * Reset wresized when doresize() completes its work > * Only call isatty(fileno(stdout)) once, instead of every time > doresize() is called > * Only install a SIGWINCH handler if isatty() is true > diff --git a/usr.sbin/iostat/iostat.c b/usr.sbin/iostat/iostat.c > --- a/usr.sbin/iostat/iostat.c > +++ b/usr.sbin/iostat/iostat.c [...] > @@ -426,6 +433,20 @@ main(int argc, char **argv) > */ > (void)signal(SIGCONT, needhdr); > > + /* > + * If our standard output is a tty, then install a SIGWINCH handler > + * and set wresized so that our first iteration through the main > + * iostat loop will peek at the terminal's current rows to find out > + * how many lines can fit in a screenful of output. > + */ > + if (isatty(fileno(stdout)) != 0) { > + wresized = 1; > + (void)signal(SIGWINCH, needresize); > + } else { > + wrows = IOSTAT_DEFAULT_ROWS; > + return; Oops. `return' doesn't belong here, of course. Running iostat | more caught what I missed :)