From pb@EU.org  Fri Dec  5 06:57:45 1997
Received: from ns.eu.org (valerian.glou.eu.org [193.56.58.251])
          by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id GAA02130
          for <FreeBSD-gnats-submit@freebsd.org>; Fri, 5 Dec 1997 06:57:37 -0800 (PST)
          (envelope-from pb@EU.org)
Received: (from pb@localhost) by ns.eu.org (8.8.7/8.7.1/951117) id PAA04190; Fri, 5 Dec 1997 15:57:29 +0100 (CET)
Message-Id: <199712051457.PAA04190@ns.eu.org>
Date: Fri, 5 Dec 1997 15:57:29 +0100 (CET)
From: pb@fasterix.frmug.org
Reply-To: pb@fasterix.frmug.org
To: FreeBSD-gnats-submit@freebsd.org
Subject: CPU and mem not zeroed for zombie process
X-Send-Pr-Version: 3.2

>Number:         5236
>Category:       kern
>Synopsis:       CPU and mem not zeroed for zombie process
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Dec  5 07:00:03 PST 1997
>Closed-Date:    Sun Apr 19 00:05:30 PDT 1998
>Last-Modified:  Sun Apr 19 00:06:06 PDT 1998
>Originator:     Pierre Beyssac
>Release:        FreeBSD 2.2.5-RELEASE i386
>Organization:
none
>Environment:

486DX50, 8 megs RAM.

>Description:

ps shows zombie processes left with non-zero %CPU and %MEM:

bash$ ps axuww
USER       PID %CPU %MEM   VSZ  RSS  TT  STAT STARTED       TIME COMMAND
pb        4076 78.4  0.1     0    0  p1  Z    -          0:00.00  (a.out)
...

The values stay stable while the zombie is in the process table.

>How-To-Repeat:

Compile the following code (trivial: forks, then the child uses
the CPU while the parent waits 10 minutes):

-------------------------------
#include <stdio.h>

int main()
{
	switch(fork()) {
	case -1:
		perror("fork");
		return 1;
	case 0:
		/* in child */
		for(;;);
		exit(0);
	default:
		/* in parent */
		sleep(600);
	}
	return 0;
}
-------------------------------

Run it:

$ ./a.out &
[1] 4075

Wait for the child to show-up with a reasonnable %CPU:

$ ps axuww | grep a.out
pb        4076 82.2  6.3   136  400  p1  R     3:46PM    0:05.60 ./a.out
pb        4075  0.0  6.4   136  404  p1  S     3:46PM    0:00.04 ./a.out

Kill the child:
$ kill 4076

Look at ps again:
pb        4076 78.4  0.1     0    0  p1  Z    -          0:00.00  (a.out)
pb        4075  0.0  0.0   136    0  p1  SW    3:46PM    0:00.04 ./a.out


>Fix:
	

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: phk 
State-Changed-When: Sun Apr 19 00:05:30 PDT 1998 
State-Changed-Why:  
I don't think this behaviour is wrong.  What do you perceive as a problem 
with it ? 
>Unformatted:
