Date: Wed, 05 Nov 2008 09:41:10 +0200 From: Diomidis Spinellis <dds@aueb.gr> To: Giorgos Keramidas <keramida@freebsd.org> Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r184645 - head/usr.bin/vmstat Message-ID: <49114E16.1090808@aueb.gr> In-Reply-To: <87tzamgbcp.fsf@kobe.laptop> References: <200811041802.mA4I2aVk003708@svn.freebsd.org> <BA9CF772-DA8B-429E-BDB8-73A65FA8CC5B@aueb.gr> <87tzamgbcp.fsf@kobe.laptop>
next in thread | previous in thread | raw e-mail | index | archive | help
Giorgos Keramidas wrote: > On Tue, 4 Nov 2008 22:30:07 +0200, Diomidis Spinellis <dds@aueb.gr> 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.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?49114E16.1090808>