Subject: bin/1347: ps avx "RE" and "SL" columns are too wide
To: None <gnats-bugs@gnats.netbsd.org>
From: Kenneth Stailey <kstailey@owl.dol-esa.gov>
List: netbsd-bugs
Date: 08/12/1995 14:46:48
>Number:         1347
>Category:       bin
>Synopsis:       ps avx "RE" and "SL" columns are too wide
>Confidential:   yes
>Severity:       non-critical
>Priority:       medium
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Aug 12 14:50:00 1995
>Last-Modified:
>Originator:     Kenneth Stailey
>Organization:
DOL/ESA/DASM
	
>Release:        Aug 9, 1995
>Environment:
really N/A
	
System: NetBSD owl 1.0A NetBSD 1.0A (OWL) #6: Fri Jul 21 09:33:23 EDT 1995 kstailey@owl:/usr/src/sys/arch/i386/compile/OWL i386


>Description:
	4.3BSD only allows 2 columns (3 if you count the space) for
	the "RE" and "SL" fields.  It truncates the values to "99"
	in order to enforce this.

	NetBSD "ps -avx" looks awful because this rule was left out.
>How-To-Repeat:
	
% ps avx
  PID STAT      TIME  SL  RE PAGEIN   VSZ  RSS   LIM TSIZ %CPU %MEM COMMAND
   19 Is     4:06.63 258 246881      0  8284  116     -  112  0.0  0.8 mfs -s 1612
  133 S     50:40.56   0 246858      0  5552  512     - 2356  0.0  3.2 /usr/X11R6/
20493 SN    22:00.23   0 160203      0  4252  180     -  112  0.0  1.1 xlock 
29487 T      0:17.43 307 20562      0  2828 2956     -  592  0.0 18.1 emacs 
[snip]

% ps avx
  PID STAT      TIME  SL  RE PAGEIN   VSZ  RSS   LIM TSIZ %CPU %MEM COMMAND
   19 Is     4:06.63  99  99      0  8284  116     -  112  0.0  0.8 mfs -s 1612
  133 S     50:40.56   0  99      0  5552  512     - 2356  0.0  3.2 /usr/X11R6/
20493 SN    22:00.23   0  99      0  4252  180     -  112  0.0  1.1 xlock 
29487 T      0:17.43  99  99      0  2828 2956     -  592  0.0 18.1 emacs 
>Fix:
	

apply these three patches:

--- ps.h.DIST	Sat Aug 12 14:31:38 1995
+++ ps.h	Fri Aug 11 20:01:44 1995
@@ -67,6 +67,7 @@
 #define	COMM	0x01		/* needs exec arguments and environment (XXX) */
 #define	LJUST	0x02		/* left adjust on output (trailing blanks) */
 #define	USER	0x04		/* needs user structure */
+#define TWODGT  0x08		/* from 0 to 99 */
 	u_int	flag;
 				/* output routine */
 	void	(*oproc) __P((struct kinfo *, struct varent *));


--- print.c.DIST	Sat Aug 12 14:31:19 1995
+++ print.c	Fri Aug 11 20:06:50 1995
@@ -718,7 +718,11 @@
 		(void)printf(ofmt, v->width, *(long *)bp);
 		break;
 	case ULONG:
-		(void)printf(ofmt, v->width, *(u_long *)bp);
+		if (v->flag & TWODGT)
+			(void)printf(ofmt, v->width,
+				*(u_long *)bp > 99L ? 99L : *(u_long *)bp);
+		else
+			(void)printf(ofmt, v->width, *(u_long *)bp);
 		break;
 	case KPTR:
 		(void)printf(ofmt, v->width, *(u_long *)bp &~ KERNBASE);


--- keyword.c.DIST	Sat Aug 12 14:31:07 1995
+++ keyword.c	Sat Aug 12 14:26:32 1995
@@ -136,7 +136,7 @@
 	{"pmem", "", "%mem"},
 	{"ppid", "PPID", NULL, 0, evar, PIDLEN, EOFF(e_ppid), LONG, PIDFMT},
 	{"pri", "PRI", NULL, 0, pri, 3},
-	{"re", "RE", NULL, 0, pvar, 3, POFF(p_swtime), ULONG, "d"},
+	{"re", "RE", NULL, TWODGT, pvar, 3, POFF(p_swtime), ULONG, "d"},
 	{"rgid", "RGID", NULL, 0, evar, UIDLEN, EOFF(e_pcred.p_rgid),
 		ULONG, UIDFMT},
 	{"rlink", "RLINK", NULL, 0, pvar, 8, POFF(p_back), KPTR, "x"},
@@ -152,7 +152,7 @@
 	{"sigignore", "IGNORED",
 		NULL, 0, pvar, 8, POFF(p_sigignore), LONG, "x"},
 	{"sigmask", "BLOCKED", NULL, 0, pvar, 8, POFF(p_sigmask), LONG, "x"},
-	{"sl", "SL", NULL, 0, pvar, 3, POFF(p_slptime), ULONG, "d"},
+	{"sl", "SL", NULL, TWODGT, pvar, 3, POFF(p_slptime), ULONG, "d"},
 	{"start", "STARTED", NULL, LJUST|USER, started, 8},
 	{"stat", "", "state"},
 	{"state", "STAT", NULL, 0, state, 4},
>Audit-Trail:
>Unformatted: