From owner-freebsd-hackers Tue Nov 28 12:43: 6 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from pike.osd.bsdi.com (pike.osd.bsdi.com [204.216.28.222]) by hub.freebsd.org (Postfix) with ESMTP id BB2AE37B400 for ; Tue, 28 Nov 2000 12:43:03 -0800 (PST) Received: from laptop.baldwin.cx (john@dhcp246.osd.bsdi.com [204.216.28.246]) by pike.osd.bsdi.com (8.11.1/8.9.3) with ESMTP id eASKgxC89628 for ; Tue, 28 Nov 2000 12:42:59 -0800 (PST) (envelope-from jhb@FreeBSD.org) Message-ID: X-Mailer: XFMail 1.4.0 on FreeBSD X-Priority: 3 (Normal) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit MIME-Version: 1.0 Date: Tue, 28 Nov 2000 12:43:12 -0800 (PST) From: John Baldwin To: hackers@FreeBSD.org Subject: Fixes to top(1) to use the full width of the screen for p_comm Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Hey gang, One of my favorite tools to use during the SMPng stuff is top(1) as I get to see all the Happy Little Processes bouncing around on CPU's and getting stuck in SMTX, etc. One annoyance is that even if the window is wider than 80 chars, top(1) will only use 80 chars of data. Notably, if someone adds some NIS user to your network one day with a 16 character username *cough*, then suddently you only get to see the first 6 characters of p_comm for each process, even if you widen the window. I looked around and found out that top was needlessly assuming that the window width was always 80 chars, so I worked up a little patch at http://www.FreeBSD.org/~jhb/patches/top.patch to teach top to use the full window width for p_comm. I'd like to commit this in a day or two if no one objects. Note that the change is in machine.c, so I _will_ _not_ _be_ _pulling_ _a_ _file_ _off_ _of_ _a_ _vendor_ _branch_. Index: machine.c =================================================================== RCS file: /host/ares/usr/home/ncvs/src/usr.bin/top/machine.c,v retrieving revision 1.30 diff -u -r1.30 machine.c --- machine.c 2000/09/07 01:32:38 1.30 +++ machine.c 2000/11/28 19:39:50 @@ -53,6 +53,7 @@ #include "top.h" #include "machine.h" +#include "screen.h" static int check_nlist __P((struct nlist *)); static int getkval __P((unsigned long, int *, int, char *)); @@ -60,7 +61,7 @@ int swapmode __P((int *retavail, int *retfree)); static int smpmode; static int namelength; -static int cmdlength; +static int cmdlengthdelta; /* get_process_info passes back a handle. This is what it looks like: */ @@ -315,7 +316,7 @@ snprintf(Header, sizeof(Header), smpmode ? smp_header : up_header, namelength, namelength, uname_field); - cmdlength = 80 - strlen(Header) + 6; + cmdlengthdelta = strlen(Header) - 7; return Header; } @@ -628,7 +629,9 @@ format_time(cputime), 100.0 * weighted_cpu(pct, pp), 100.0 * pct, - cmdlength, + screen_width > cmdlengthdelta ? + screen_width - cmdlengthdelta : + 0, printable(PP(pp, p_comm))); /* return the result */ -- John Baldwin -- http://www.FreeBSD.org/~jhb/ PGP Key: http://www.baldwin.cx/~john/pgpkey.asc "Power Users Use the Power to Serve!" - http://www.FreeBSD.org/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message