From owner-freebsd-current Sat Jul 5 03:25:22 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.5/8.8.5) id DAA00251 for current-outgoing; Sat, 5 Jul 1997 03:25:22 -0700 (PDT) Received: from bsd.fs.bauing.th-darmstadt.de (bsd.fs.bauing.th-darmstadt.de [130.83.63.241]) by hub.freebsd.org (8.8.5/8.8.5) with ESMTP id DAA00240 for ; Sat, 5 Jul 1997 03:25:19 -0700 (PDT) Received: from panke.panke.de (anonymous213.ppp.cs.tu-berlin.de [130.149.17.213]) by bsd.fs.bauing.th-darmstadt.de (8.8.5/8.8.5) with ESMTP id MAA20586 for ; Sat, 5 Jul 1997 12:25:15 +0200 (MET DST) Received: (from wosch@localhost) by panke.panke.de (8.8.5/8.6.12) id MAA00736; Sat, 5 Jul 1997 12:01:32 +0200 (MET DST) Date: Sat, 5 Jul 1997 12:01:32 +0200 (MET DST) Message-Id: <199707051001.MAA00736@panke.panke.de> From: Wolfram Schneider To: current@freebsd.org Subject: long usernames in top MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Sender: owner-current@freebsd.org X-Loop: FreeBSD.org Precedence: bulk The long usernames in top(1) looks not well. In most cases the usernames are less than 8 chars. Top reserves 16 chars for the username in the output string. Here is a workaround. Top should print only the first 10 characters. If the username is longer than 10 characters, the 10th character will be replaces with an asterisk ('*'). An other alternative would be to use the uid instead the long username. Index: contrib/top/username.c =================================================================== RCS file: /usr/cvs/src/contrib/top/username.c,v retrieving revision 1.2 diff -u -r1.2 username.c --- username.c 1997/04/21 13:52:29 1.2 +++ username.c 1997/07/04 22:49:35 @@ -126,7 +126,9 @@ /* empty or wrong slot -- fill it with new value */ hash_table[hashindex].uid = uid; - (void) strncpy(hash_table[hashindex].name, name, UT_NAMESIZE); + (void) strncpy(hash_table[hashindex].name, name, 10); + if (strlen(name) > 10) + *(hash_table[hashindex].name + 9) = '*'; return(hashindex); } Index: usr.bin/top/machine.c =================================================================== RCS file: /usr/cvs/src/usr.bin/top/machine.c,v retrieving revision 1.3 diff -u -r1.3 machine.c --- machine.c 1997/04/21 13:53:47 1.3 +++ machine.c 1997/07/04 10:21:54 @@ -122,22 +122,22 @@ #ifdef P_IDLEPROC /* FreeBSD SMP kernel */ static char header[] = - " PID X PRI NICE SIZE RES STATE C TIME WCPU CPU COMMAND"; + " PID X PRI NICE SIZE RES STATE C TIME WCPU CPU COMMAND"; /* 0123456 -- field to fill in starts at header+6 */ #define UNAME_START 6 #define Proc_format \ - "%5d %-16.16s%3d%3d%7s %6s %-6.6s%1x%7s %5.2f%% %5.2f%% %.6s" + "%5d %-10.10s%3d%3d%7s %6s %-6.6s%1x%7s %5.2f%% %5.2f%% %.6s" #else /* Standard kernel */ static char header[] = - " PID X PRI NICE SIZE RES STATE TIME WCPU CPU COMMAND"; + " PID X PRI NICE SIZE RES STATE TIME WCPU CPU COMMAND"; /* 0123456 -- field to fill in starts at header+6 */ #define UNAME_START 6 #define Proc_format \ - "%5d %-16.16s%3d %3d%7s %6s %-6.6s%7s %5.2f%% %5.2f%% %.6s" + "%5d %-10.10s%3d %3d%7s %6s %-6.6s%7s %5.2f%% %5.2f%% %.6s" #endif -- Wolfram Schneider http://www.apfel.de/~wosch/