Bug 91145 - ps confuses genuine child processes with threads
Summary: ps confuses genuine child processes with threads
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: procps
Version: 8.0
Hardware: i386
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Daniel Walsh
QA Contact: Brian Brock
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2003-05-19 13:30 UTC by Kevin Swift
Modified: 2007-04-18 16:53 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2004-02-11 13:28:32 UTC
Embargoed:


Attachments (Terms of Use)

Description Kevin Swift 2003-05-19 13:30:30 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20021130

Description of problem:
ps has been changed to not report multiple processes for threads of the same
process. The problem here is that ps gets very confused and often forgets to
report child processes even when they have a different name.

The following program shows the problem.


main ()
{
        int i;

        for (i=0; i<10; i++)
        {
                if (fork()==0)
                {
                        sleep(100);
                        exit(0);
                }
        }

        sleep (100);

        exit (0);
}

When running this program on 7.2 you get.

$ps
  PID TTY          TIME CMD
26467 pts/40   00:00:01 bash
 5488 pts/40   00:00:00 a.out
 5489 pts/40   00:00:00 a.out
 5490 pts/40   00:00:00 a.out
 5491 pts/40   00:00:00 a.out
 5492 pts/40   00:00:00 a.out
 5493 pts/40   00:00:00 a.out
 5494 pts/40   00:00:00 a.out
 5495 pts/40   00:00:00 a.out
 5496 pts/40   00:00:00 a.out
 5497 pts/40   00:00:00 a.out
 5498 pts/40   00:00:00 a.out
 5499 pts/40   00:00:00 ps

on 8 & 9 you get.

$ ps
  PID TTY          TIME CMD
  565 pts/4    00:00:00 bash
25608 pts/4    00:00:00 a.out
25645 pts/4    00:00:00 ps


We have also seen problems with processes in a pipe, all with different names.
ps does not report them all without the -m option.
[ could not get an example of this to work at the moment. when I do I
will attach it ]




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


How reproducible:
Always

Comment 1 Kevin Swift 2003-05-19 13:40:37 UTC
Here is another example.


The end of a ps -ef list......

root     11476 11475  0 May13 ?        00:00:00 host tickle.samsungcontact.com
root     11477 11475  0 May13 ?        00:00:00 awk  $0 ~ /has address/ {print $1}
root     11472 11437  0 May13 ?        00:00:00 /bin/sh
/build/contact-test/tests/scripts/omlocalhost
root     25280  1617  0 13:40 ?        00:00:00 /usr/sbin/sshd
root     25284 25280  0 13:40 pts/1    00:00:00 -bash
root     25336  1617  0 13:41 ?        00:00:00 /usr/sbin/sshd
sshd     25337 25336  0 13:41 ?        00:00:00 [sshd]
markd    25342 25197  0 13:41 pts/0    00:00:00 ps -ef

[markd@tickle logs]$ps -ef |grep 11475

root     11476 11475  0 May13 ?        00:00:00 host tickle.samsungcontact.com
root     11477 11475  0 May13 ?        00:00:00 awk  $0 ~ /has address/ {print $1}
markd    25347 25197  0 13:41 pts/0    00:00:00 grep 11475

[markd@tickle logs]$ ps -mef | grep 11475

root     11475 11472  0 May13 ?        00:00:00 /bin/sh
/build/contact-test/tests/scripts/omlocalhost
root     11476 11475  0 May13 ?        00:00:00 host tickle.samsungcontact.com
root     11477 11475  0 May13 ?        00:00:00 awk  $0 ~ /has address/ {print $1}
markd    25355 25197  0 13:42 pts/0    00:00:00 grep 11475


In the last output notice that process 11475 appears but the other ps outputs
somehow missed it!! As it's the parent of the other processes you would expect
to see it always. Is 11472(in first list) hiding it's child 11475?

Comment 2 Alexander Larsson 2003-05-21 09:11:08 UTC
You can't reliably detect subtreads when using LinuxThreads, so an heuristic is
used. A process is considered a thread if it has the same vmsize, rss and name
as its parent. This isn't perfect, but it was hoped that it would lead to few
problems in the real world. When you are using NPTL threads can be reliably
detected, so this problem will go away in the future.

However, you said you had problems where the child had a different name. That
seems like a real bug. I wonder if the /bin/sh example you showed accidentally
had identical rss and vmsize for the shell.

Comment 3 Joseph Shraibman 2003-06-18 01:25:47 UTC
Is this fixed in redhat 9?

Comment 4 Daniel Walsh 2004-02-11 13:28:32 UTC
Fixed by using latest threads. NPTL.

Dan


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