Bug 89942 - 2nd+ forked processes only show up in ps as threads
Summary: 2nd+ forked processes only show up in ps as threads
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: procps
Version: 8.0
Hardware: i686
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Alexander Larsson
QA Contact: Brian Brock
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2003-04-30 03:04 UTC by Charles Churchill II
Modified: 2007-04-18 16:53 UTC (History)
0 users

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2003-04-30 08:23:00 UTC
Embargoed:


Attachments (Terms of Use)

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).



Note You need to log in before you can comment on or make changes to this bug.