Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.os.linux.misc > #12623 > unrolled thread

Output of pstree -p <pid> shows threads with different pids

Started byAdam Stanton <adamstanton1979@gmail.com>
First post2014-11-05 09:44 -0800
Last post2014-11-05 11:52 -0800
Articles 5 — 2 participants

Back to article view | Back to comp.os.linux.misc


Contents

  Output of pstree -p <pid> shows threads with different pids Adam Stanton <adamstanton1979@gmail.com> - 2014-11-05 09:44 -0800
    Re: Output of pstree -p <pid> shows threads with different pids Richard Kettlewell <rjk@greenend.org.uk> - 2014-11-05 18:23 +0000
      Re: Output of pstree -p <pid> shows threads with different pids Adam Stanton <adamstanton1979@gmail.com> - 2014-11-05 11:05 -0800
        Re: Output of pstree -p <pid> shows threads with different pids Richard Kettlewell <rjk@greenend.org.uk> - 2014-11-05 19:34 +0000
          Re: Output of pstree -p <pid> shows threads with different pids Adam Stanton <adamstanton1979@gmail.com> - 2014-11-05 11:52 -0800

#12623 — Output of pstree -p <pid> shows threads with different pids

FromAdam Stanton <adamstanton1979@gmail.com>
Date2014-11-05 09:44 -0800
SubjectOutput of pstree -p <pid> shows threads with different pids
Message-ID<20141105094408.3d6d3fec@adam>
I ran the program pstree -p 31872 which printed the following output:

ruby(31872)─┬─{ruby}(31906)
            └─{ruby}(32372)

The man page for pstree says:

Child threads of a process are found under the parent process and are
shown with the process name in curly braces, e.g.

           icecast2---13*[{icecast2}]

(The above is different output because of the missing -p option.
However running pstree 31872 gives:

ruby───2*[{ruby}]

which suggests a ruby process running 2 ruby threads. 

My question is, why does the -p option show the threads with different
pids? I would expect them to be the same (31872) as the process. Running
htop also shows the same results.

[toc] | [next] | [standalone]


#12624

FromRichard Kettlewell <rjk@greenend.org.uk>
Date2014-11-05 18:23 +0000
Message-ID<wwvd291tsl2.fsf@l1AntVDjLrnP7Td3DQJ8ynzIq3lJMueXf87AxnpFoA.invalid>
In reply to#12623
Adam Stanton <adamstanton1979@gmail.com> writes:
> I ran the program pstree -p 31872 which printed the following output:
>
> ruby(31872)─┬─{ruby}(31906)
>             └─{ruby}(32372)
>
> The man page for pstree says:
>
> Child threads of a process are found under the parent process and are
> shown with the process name in curly braces, e.g.
>
>            icecast2---13*[{icecast2}]
>
> (The above is different output because of the missing -p option.
> However running pstree 31872 gives:
>
> ruby───2*[{ruby}]
>
> which suggests a ruby process running 2 ruby threads. 
>
> My question is, why does the -p option show the threads with different
> pids? I would expect them to be the same (31872) as the process. Running
> htop also shows the same results.

“-p implicitly disables compaction” according to the man page.

-- 
http://www.greenend.org.uk/rjk/

[toc] | [prev] | [next] | [standalone]


#12625

FromAdam Stanton <adamstanton1979@gmail.com>
Date2014-11-05 11:05 -0800
Message-ID<20141105110501.6cc10824@adam>
In reply to#12624
On Wed, 05 Nov 2014 18:23:05 +0000
Richard Kettlewell <rjk@greenend.org.uk> wrote:

> Adam Stanton <adamstanton1979@gmail.com> writes:
> > I ran the program pstree -p 31872 which printed the following
> > output:
> >
> > ruby(31872)─┬─{ruby}(31906)
> >             └─{ruby}(32372)
> >
> > The man page for pstree says:
> >
> > Child threads of a process are found under the parent process and
> > are shown with the process name in curly braces, e.g.
> >
> >            icecast2---13*[{icecast2}]
> >
> > (The above is different output because of the missing -p option.
> > However running pstree 31872 gives:
> >
> > ruby───2*[{ruby}]
> >
> > which suggests a ruby process running 2 ruby threads. 
> >
> > My question is, why does the -p option show the threads with
> > different pids? I would expect them to be the same (31872) as the
> > process. Running htop also shows the same results.
> 
> “-p implicitly disables compaction” according to the man page.
> 

True enough, but why are the pids different? If these are threads, then
should the pids be the same as the process?

[toc] | [prev] | [next] | [standalone]


#12626

FromRichard Kettlewell <rjk@greenend.org.uk>
Date2014-11-05 19:34 +0000
Message-ID<wwv1tphtp9a.fsf@l1AntVDjLrnP7Td3DQJ8ynzIq3lJMueXf87AxnpFoA.invalid>
In reply to#12625
Adam Stanton <adamstanton1979@gmail.com> writes:
> True enough, but why are the pids different? If these are threads, then
> should the pids be the same as the process?

Oh, apologies, I completely misinterpreted what you were asking.  The
values attached to the threads will be thread IDs, not PIDs.  See ‘man
gettid’ and (in particular) the CLONE_THREAD section of ‘man clone’.

-- 
http://www.greenend.org.uk/rjk/

[toc] | [prev] | [next] | [standalone]


#12627

FromAdam Stanton <adamstanton1979@gmail.com>
Date2014-11-05 11:52 -0800
Message-ID<20141105115236.2673c532@adam>
In reply to#12626
On Wed, 05 Nov 2014 19:34:57 +0000
Richard Kettlewell <rjk@greenend.org.uk> wrote:

> Adam Stanton <adamstanton1979@gmail.com> writes:
> > True enough, but why are the pids different? If these are threads,
> > then should the pids be the same as the process?
> 
> Oh, apologies, I completely misinterpreted what you were asking.  The
> values attached to the threads will be thread IDs, not PIDs.  See ‘man
> gettid’ and (in particular) the CLONE_THREAD section of ‘man clone’.
> 

Ahh, makes perfect sense now (although docs could clear up the
ambiguity for those particular tools), thanks so much!

[toc] | [prev] | [standalone]


Back to top | Article view | comp.os.linux.misc


csiph-web