svn commit: r184645 - head/usr.bin/vmstat
Diomidis Spinellis
dds at aueb.gr
Tue Nov 4 23:41:57 PST 2008
Giorgos Keramidas wrote:
> On Tue, 4 Nov 2008 22:30:07 +0200, Diomidis Spinellis <dds at 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.
More information about the svn-src-all
mailing list