Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
ps and threads
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
mix32
n00b
n00b


Joined: 20 Nov 2005
Posts: 16

PostPosted: Tue Dec 27, 2005 9:55 pm    Post subject: ps and threads Reply with quote

When I type "ps" multi-threaded programs appear several times, as if they were separated processes. I'd like to see only one line per process (some other distros do it). Is it possible?
Back to top
View user's profile Send private message
Jake
Veteran
Veteran


Joined: 31 Jul 2003
Posts: 1132

PostPosted: Tue Dec 27, 2005 10:13 pm    Post subject: Reply with quote

Are you sure you're seeing multiple threads and not multiple processes? My "ps" only shows threads with H, -L, -T, m, and -m, the behavior documented in the man page. Otherwise each line displays a unique PID. Please provide an example.
Back to top
View user's profile Send private message
anonybosh
Guru
Guru


Joined: 20 Nov 2005
Posts: 324

PostPosted: Tue Dec 27, 2005 10:16 pm    Post subject: Reply with quote

One possible way to do this (though it does drop most info, and includes the CMD from the top description) is:
Code:
# ps -A|gawk '{print $4}'|sort|uniq
CMD
agetty
ahc_dv_0
aio/0
aio/1
apache2
apcupsd
bash
cron
...


Rather worthless, yet shows you a list of what's running.
Back to top
View user's profile Send private message
mix32
n00b
n00b


Joined: 20 Nov 2005
Posts: 16

PostPosted: Wed Dec 28, 2005 12:26 am    Post subject: Reply with quote

Jake wrote:
Are you sure you're seeing multiple threads and not multiple processes? My "ps" only shows threads with H, -L, -T, m, and -m, the behavior documented in the man page. Otherwise each line displays a unique PID. Please provide an example.


Well, for example ps shows multiple instances of xmms or mozilla-firefox (which are multi-threaded apps)
Back to top
View user's profile Send private message
Jake
Veteran
Veteran


Joined: 31 Jul 2003
Posts: 1132

PostPosted: Wed Dec 28, 2005 12:55 am    Post subject: Reply with quote

mix32 wrote:
Well, for example ps shows multiple instances of xmms or mozilla-firefox (which are multi-threaded apps)

Like this?
Code:
$ ps mx
...
 8491 ?        -      0:20 /usr/bin/xmms --sm-client-id 117f00000100010973926310
    - -        Rsl    0:20 -
    - -        Ssl    0:00 -
    - -        Ssl    0:00 -
...
 8607 ?        -     18:20 /opt/firefox/firefox-bin
    - -        Sl    18:09 -
    - -        Sl     0:02 -
    - -        Sl     0:07 -
    - -        Sl     0:00 -
    - -        Sl     0:00 -
    - -        Sl     0:00 -
    - -        Sl     0:00 -
...

instead of
Code:
$ ps x
...
 8491 ?        Ssl    0:20 /usr/bin/xmms --sm-client-id 117f00000100010973926310
...
 8607 ?        Sl    18:21 /opt/firefox/firefox-bin
...

Do you have any aliases (look for ps in "alias" output) or envoronment variables (look for anything containing PS in "env" output) that might be affecting output?
Back to top
View user's profile Send private message
mix32
n00b
n00b


Joined: 20 Nov 2005
Posts: 16

PostPosted: Wed Dec 28, 2005 1:27 am    Post subject: Reply with quote

No, I don't have any aliases or environment variables containing ps. This is what i get:

$ ps -A u |grep xmms
- 6859 7.3 2.4 32876 6812 pts/0 S 02:23 0:00 xmms
- 6860 0.0 2.4 32876 6812 pts/0 S 02:23 0:00 xmms
- 6861 0.0 2.4 32876 6812 pts/0 S 02:23 0:00 xmms
- 6862 0.0 2.4 32876 6812 pts/0 S 02:23 0:00 xmms
- 6864 0.0 0.1 1560 468 pts/0 S+ 02:23 0:00 grep xmms


And:

$ ls /proc/6859/task/
6859
Back to top
View user's profile Send private message
PowerFactor
Veteran
Veteran


Joined: 30 Jan 2003
Posts: 1693
Location: out of it

PostPosted: Wed Dec 28, 2005 1:51 am    Post subject: Reply with quote

Seeing a separate process for every thread in ps is normal with the old linuxthreads library. If you add nptl to your USE flags and recompile glibc you should get the behavior you've seen in other distros.
Back to top
View user's profile Send private message
mix32
n00b
n00b


Joined: 20 Nov 2005
Posts: 16

PostPosted: Wed Dec 28, 2005 12:01 pm    Post subject: Reply with quote

PowerFactor wrote:
Seeing a separate process for every thread in ps is normal with the old linuxthreads library. If you add nptl to your USE flags and recompile glibc you should get the behavior you've seen in other distros.


It worked! Thanks.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum