View previous topic :: View next topic |
Author |
Message |
mix32 n00b
Joined: 20 Nov 2005 Posts: 16
|
Posted: Tue Dec 27, 2005 9:55 pm Post subject: ps and threads |
|
|
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 |
|
|
Jake Veteran
Joined: 31 Jul 2003 Posts: 1132
|
Posted: Tue Dec 27, 2005 10:13 pm Post subject: |
|
|
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 |
|
|
anonybosh Guru
Joined: 20 Nov 2005 Posts: 324
|
Posted: Tue Dec 27, 2005 10:16 pm Post subject: |
|
|
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 |
|
|
mix32 n00b
Joined: 20 Nov 2005 Posts: 16
|
Posted: Wed Dec 28, 2005 12:26 am Post subject: |
|
|
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 |
|
|
Jake Veteran
Joined: 31 Jul 2003 Posts: 1132
|
Posted: Wed Dec 28, 2005 12:55 am Post subject: |
|
|
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 |
|
|
mix32 n00b
Joined: 20 Nov 2005 Posts: 16
|
Posted: Wed Dec 28, 2005 1:27 am Post subject: |
|
|
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 |
|
|
PowerFactor Veteran
Joined: 30 Jan 2003 Posts: 1693 Location: out of it
|
Posted: Wed Dec 28, 2005 1:51 am Post subject: |
|
|
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 |
|
|
mix32 n00b
Joined: 20 Nov 2005 Posts: 16
|
Posted: Wed Dec 28, 2005 12:01 pm Post subject: |
|
|
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 |
|
|
|