Subject: bin/2693: ps reports %cpu > 0 for zombies.
To: None <gnats-bugs@NetBSD.ORG>
From: Kenneth Stailey <kstailey@dol-esa.gov>
List: netbsd-bugs
Date: 08/12/1996 22:42:38
>Number:         2693
>Category:       bin
>Synopsis:       ps reports %cpu > 0 for zombies.
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Aug 12 23:20:23 1996
>Last-Modified:
>Originator:     Kenneth Stailey
>Organization:
DOL/ESA/DASM
>Release:        1.2_BETA
>Environment:
System: NetBSD owl 1.2_BETA NetBSD 1.2_BETA (OWL) #0: Mon Jul 15 23:55:53 EDT 1996 kstailey@owl:/usr/src/sys/arch/i386/compile/OWL i386


>Description:
exit() does not clear p_pctcpu so ps can show zombies using %cpu > 0.
"ps -axu" even sorts them to the top.

>How-To-Repeat:
While running NetScape Navagator 2.x run "ps -axu | head".  Look for zombie
copy of netstat.

>Fix:
in  src/bin/ps

--- print.c.DIST	Mon Aug 12 22:13:11 1996
+++ print.c	Mon Aug 12 22:16:43 1996
@@ -556,7 +556,8 @@
 #define	fxtofl(fixpt)	((double)(fixpt) / fscale)
 
 	/* XXX - I don't like this */
-	if (p->p_swtime == 0 || (p->p_flag & P_INMEM) == 0)
+	if (p->p_stat == SZOMB || p->p_swtime == 0 ||
+	   (p->p_flag & P_INMEM) == 0)
 		return (0.0);
 	if (rawcpu)
 		return (100.0 * fxtofl(p->p_pctcpu));
>Audit-Trail:
>Unformatted: