Bug 89942

Summary: 2nd+ forked processes only show up in ps as threads
Product: [Retired] Red Hat Linux Reporter: Charles Churchill II <churchill>
Component: procpsAssignee: Alexander Larsson <alexl>
Status: CLOSED CURRENTRELEASE QA Contact: Brian Brock <bbrock>
Severity: medium Docs Contact:
Priority: medium    
Version: 8.0   
Target Milestone: ---   
Target Release: ---   
Hardware: i686   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2003-04-30 08:23:00 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Charles Churchill II 2003-04-30 03:04:43 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.3) Gecko/20030312

Description of problem:
If an application forks more than once, the processes beginning with the  seconf
fork and on will not show up in the ps -ef  output. They do show up in the ps
-efm output. Specifying ps -p $pid_num will also display the correct
information. The proc filesystem DOES have the correct information for the
missing processes.

The following program can be used to reprod

Version-Release number of selected component (if applicable):
procps-2.0.7

How reproducible:
Always

Steps to Reproduce:
1. Compile the following program. gcc -o pid_test pid_test.c

#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>


int main()
{
  pid_t pid;

  pid = fork();
  if(pid == 0)
    {
      sleep(10000);
      exit(0);
    }

  printf("Child1 pid == %d\n",pid);

  pid = fork();
  if(pid != 0)
    {
      printf("Child2 pid == %d\n", pid);
    }

  sleep(10000);

  return 0;

}

2. Run the program: ./pid_test

3. ps -ef | grep pid_test





Actual Results:  You will only see listing for two instances of pid_test.

run the following command: ps -efm | grep pid_test
and you will see all three processes.

Expected Results:  all three processes should be listed. The fork call should
not prodice a light-weight process.

Additional info:

Comment 1 Alexander Larsson 2003-04-30 08:23:00 UTC
This is due to the way "threads" are detected in ps. Basically it just looks for
children with the exact same VMSIZE as the parent. If the child does any real
work it will typically not show up like this.

This is fixed in RHL 9 with then new threading model (NPTL).