From owner-svn-src-head@FreeBSD.ORG Wed Nov 5 07:41:57 2008 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F41901065677; Wed, 5 Nov 2008 07:41:56 +0000 (UTC) (envelope-from dds@aueb.gr) Received: from mx-out.forthnet.gr (mx-out.forthnet.gr [193.92.150.104]) by mx1.freebsd.org (Postfix) with ESMTP id 6DE8B8FC13; Wed, 5 Nov 2008 07:41:55 +0000 (UTC) (envelope-from dds@aueb.gr) Received: from mx-av-05.forthnet.gr (mx-av.forthnet.gr [193.92.150.27]) by mx-out-03.forthnet.gr (8.14.3/8.14.3) with ESMTP id mA57gaYI013411; Wed, 5 Nov 2008 09:42:36 +0200 Received: from MX-IN-02.forthnet.gr (mx-in-02.forthnet.gr [193.92.150.185]) by mx-av-05.forthnet.gr (8.14.3/8.14.3) with ESMTP id mA57frjY011532; Wed, 5 Nov 2008 09:41:53 +0200 Received: from [192.168.136.16] (adsl81-74.kln.forthnet.gr [77.49.48.74]) by MX-IN-02.forthnet.gr (8.14.3/8.14.3) with ESMTP id mA57f7dF022567; Wed, 5 Nov 2008 09:41:08 +0200 Authentication-Results: MX-IN-02.forthnet.gr smtp.mail=dds@aueb.gr; spf=neutral Authentication-Results: MX-IN-02.forthnet.gr header.from=dds@aueb.gr; sender-id=neutral Message-ID: <49114E16.1090808@aueb.gr> Date: Wed, 05 Nov 2008 09:41:10 +0200 From: Diomidis Spinellis User-Agent: Thunderbird 2.0.0.17 (Windows/20080914) MIME-Version: 1.0 To: Giorgos Keramidas References: <200811041802.mA4I2aVk003708@svn.freebsd.org> <87tzamgbcp.fsf@kobe.laptop> In-Reply-To: <87tzamgbcp.fsf@kobe.laptop> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r184645 - head/usr.bin/vmstat X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Nov 2008 07:41:57 -0000 Giorgos Keramidas wrote: > On Tue, 4 Nov 2008 22:30:07 +0200, Diomidis Spinellis wrote: >> On Nov 4, 2008, at 8:02 PM, Giorgos Keramidas wrote: >>> Author: keramida (doc committer) >>> Date: Tue Nov 4 18:02:35 2008 >>> New Revision: 184645 >>> URL: http://svn.freebsd.org/changeset/base/184645 >>> >>> Log: >>> Repeat vmstat header after window.rows instead of a hardcoded 20. >>> >>> Use ioctl() to get the window size in vmstat(8), and force a new >>> header to be prepended to the output every time the current window >>> size changes. Change the number of lines before each header to the >>> current lines of the terminal when the terminal is resized, so that >>> the full terminal length can be used for output lines. >>> >>> Inspired by: svn change 175562 (same feature for iostat) >>> Reviewed by: ru (who fixed some of my bugs too) >> Thanks! This functionality is generally useful and tricky to code in a >> correct way. Should we perhaps package it in a library function, so >> that all header-printing commands can benefit from it, without >> repeating the code? > > That's what I thought when I had to write almost the same code a second > time. Once is ok, twice is almost ok, but if we find it repeated all > over the place a library function would definitely be nice :) > > One of the utilities that includes a similar `repeated output' mode that > I was planning to patch next is procstat(1). Right now procstat prints > the header once, and then forgets about it. When the header scrolls off > the terminal it's gone for good. > > The code of procstat is quite different that vmstat and iostat though, > so I'll have to think a bit about the best way to make a library > function out of the header display code and link all three of them to > the same code. > And let us not forget netstat and nfsstat (both seem to use a hard-coded terminal size). Let me remark (without actually suggesting that we go down that road) that the old-school Unix approach to this problem might be to create a separate program that would add a specified header to its input.