Subject: bin/7058: ps shows negative RSS (patch supplied)
To: None <gnats-bugs@gnats.netbsd.org>
From: Wolfgang Helbig <helbig@Informatik.BA-Stuttgart.DE>
List: netbsd-bugs
Date: 02/27/1999 17:25:51
>Number:         7058
>Category:       bin
>Synopsis:       ps shows negative RSS (patch supplied)
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Feb 27 08:35:01 1999
>Last-Modified:
>Originator:     Wolfgang Helbig
>Organization:
	
>Release:        NetBSD-current Feb 26
>Environment:
	
System: NetBSD rvc1 1.3I NetBSD 1.3I (RVC1) #0: Sat Feb 27 16:22:02 CET 1999 helbig@rvc1:/usr/src/sys/arch/i386/compile/RVC1 i386


>Description:
	"ps alx" shows negative RSS for kernel processes.
	This messes up the output.
>How-To-Repeat:
	
>Fix:
--- bin/ps/print.c.orig	Wed Jul 29 13:03:41 1998
+++ bin/ps/print.c	Sat Feb 27 17:14:57 1999
@@ -482,10 +482,12 @@
 	VARENT *ve;
 {
 	VAR *v;
+	int s;
 
 	v = ve->var;
 	/* XXX don't have info about shared */
-	(void)printf("%*d", v->width, pgtok(KI_EPROC(k)->e_vm.vm_rssize));
+	(void)printf("%*d", v->width,
+	(s = pgtok(KI_EPROC(k)->e_vm.vm_rssize)) > 0 ? s : 0);
 }
 
 void
@@ -494,9 +496,11 @@
 	VARENT *ve;
 {
 	VAR *v;
+	int s;
 
 	v = ve->var;
-	(void)printf("%*d", v->width, pgtok(KI_EPROC(k)->e_vm.vm_rssize));
+	(void)printf("%*d", v->width,
+	(s = pgtok(KI_EPROC(k)->e_vm.vm_rssize)) > 0 ? s : 0);
 }
 
 void
>Audit-Trail:
>Unformatted: