LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 06-10-2006, 01:45 PM   #1
deckert
LQ Newbie
 
Registered: Jun 2006
Location: South Africa
Distribution: Slackware
Posts: 7

Rep: Reputation: 0
'ps' showing threads... grrr


Hi,

I've switched back to Slackware (from RedHat) when Slackware 10.1 was released. It's been mostly painless, but I have one niggling little thing left to understand.

Under RedHat9+/FC when you do a process list, the list would exclude application threads, showing processes as single line entries (as it should be).

With Slackware 10.2, 'ps' shows all the threads for the application as well.

I found some information on:
procps.sourceforge.net/faq.html

There, they state the following:

"Why do ps and top show threads individually?

The 2.4.xx kernel does not provide proper support for grouping threads by process. Hacks exist to group them anyway, but such hacks will falsely group similar tasks and will fail to group tasks due to race conditions. The hacks are also slow. As none of this is acceptable in a critical system tool, task grouping is not currently available for the 2.4.xx kernel. The 2.6.xx kernel allows for proper thread grouping and reporting. To take advantage of this, your programs must use a threading library that features the CLONE_THREAD flag. The NPTL pthreads provided by recent glibc releases use CLONE_THREAD."


Now, I'm using the 2.6.16.19 kernel and Slackware reports "NPTL 2.3.5" when I do a "getconf GNU_LIBPTHREAD_VERSION". That's fairly recent if I understand correctly, but threads still are displayed with a normal process list.

If I want to surpress the listing of threads, should I change something on 'ps' itself, or am I missing something else?

--deckert
 
Old 06-10-2006, 02:06 PM   #2
theoffset
Member
 
Registered: Aug 2005
Location: Guadalajara, Jal, Mexico
Distribution: Slackware Linux
Posts: 211

Rep: Reputation: 31
Mmm...I don't get a list of threads unless I explicitly tell ps to do so.

Maybe you should check the enviroment variables PS_PERSONALITY and CMD_ENV, they both should be either cleared or set to "linux".

Or perhaps you are actually telling ps to show you the thread info?

try "ps axu" or "ps -ely" (the "-" DO makes difference)

Last edited by theoffset; 06-10-2006 at 02:11 PM.
 
Old 06-10-2006, 06:25 PM   #3
deckert
LQ Newbie
 
Registered: Jun 2006
Location: South Africa
Distribution: Slackware
Posts: 7

Original Poster
Rep: Reputation: 0
Hi,

Quote:
Originally Posted by theoffset
Mmm...I don't get a list of threads unless I explicitly tell ps to do so.
It's a standard Slack 10.2 install without any mods, except for kernel 2.6.16.19, but I also tried it with the stock kernel now and I get the same thing.

Java threads all show up as zillions of processes. If I use ps -axf to get a 'forest' I can see the threads all dangling below the main java thread. Do the same on a RedHat box and you only see the process, not the threads. Specify ps -axfm and it shows the threads again.

I also checked PS_PERSONALITY, CMD_ENV and they're not set. There also aren't any aliases defined for 'ps' that may cause the threads to show.

Here's a sample of what it looks like:
Code:
root@machine:~# ps -axf
  PID TTY      STAT   TIME COMMAND
 2259 ?        S      0:01  \_ /usr/local/java/jdk1.5/bin/java
 2262 ?        S      0:00  |   \_ /usr/local/java/jdk1.5/bin/java
 2263 ?        S      0:20  |       \_ /usr/local/java/jdk1.5/bin/java
 2264 ?        S      0:00  |       \_ /usr/local/java/jdk1.5/bin/java
 2265 ?        S      0:01  |       \_ /usr/local/java/jdk1.5/bin/java
 2266 ?        S      0:00  |       \_ /usr/local/java/jdk1.5/bin/java
 2267 ?        S      0:00  |       \_ /usr/local/java/jdk1.5/bin/java
 2268 ?        S      0:10  |       \_ /usr/local/java/jdk1.5/bin/java
I'm baffled by this behaviour.

**EDIT**

Code:
Here's what it looks like on the RedHat box:

  PID TTY      STAT   TIME COMMAND
 4130 pts/9    Sl+    1:42   \_ /usr/local/java/jdk1.5/bin/java -server -Xincgc -Xnoclassgc -Xms51
Note that 'ps' on the RedHat box correctly displays STATE "Sl+" indicating that the process is multi-threaded. I'm beginning to suspect either some thread brokenness in Slack 10.2 or a broken 'ps'.

--deckert

Last edited by deckert; 06-10-2006 at 07:55 PM.
 
Old 06-10-2006, 11:07 PM   #4
theoffset
Member
 
Registered: Aug 2005
Location: Guadalajara, Jal, Mexico
Distribution: Slackware Linux
Posts: 211

Rep: Reputation: 31
Code:
$ ps -afx
Warning: bad ps syntax, perhaps a bogus '-'? See http://procps.sf.net/faq.html
[...]
Looking in "man ps", there's no "-x" option (but there's a "x" option, without a leading "-").

Perhaps you wanted to run "ps afx" which will show you all processes in a three (but no threads)?

I'm thinking that maybe the RedHat's "ps" program is patched to detect this kind of typos and fix them... or maybe they are running another version of ps... just out of curiousity, what does RedHat prints with "ps --version" and what's the value of the already said variables?


EDIT: Just found out that the stat "Sl+" will only be shown when running a BSD command:
Quote:
Originally Posted by man_ps
For BSD formats and when the stat keyword is used, additional characters may be displayed:
[snip]
l is multi-threaded (using CLONE_THREAD, like NPTL pthreads do)
+ is in the foreground process group
So maybe your PERSONALITY_PS or CMD_ENV are set to bsd under RedHat ??

EDIT 2:
Yep, I'm thinking that a PERSONALITY_PS=bsd might be the reason.
Code:
PERSONALITY_PS=bsd ps -afx
shows no Warning message and the threads are not shown. Also, the correct Stat code (Sl+) seems to be shown for threaded processes (in this case seamonkey-bin and bittorent-curses (python)).

Maybe you should set this variable in your .profile or the system-wide /etc/profile if you want the same behaviour than RedHat...

Last edited by theoffset; 06-10-2006 at 11:24 PM.
 
Old 06-10-2006, 11:30 PM   #5
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Could you also post an example of what you'd EXPECT to get, or
what DeadRat displays with the same options?


Cheers,
Tink
 
Old 06-11-2006, 06:15 AM   #6
deckert
LQ Newbie
 
Registered: Jun 2006
Location: South Africa
Distribution: Slackware
Posts: 7

Original Poster
Rep: Reputation: 0
Hi,

Quote:
Originally Posted by theoffset
Code:
$ ps -afx
Warning: bad ps syntax, perhaps a bogus '-'? See procps.sf.net/faq.html
[...]
You get the above on a Slack 10.2 box? Mine doesn't give that error.

Quote:
Perhaps you wanted to run "ps afx" which will show you all processes in a three (but no threads)?
Did that too and the output remains the same.

Quote:
another version of ps... just out of curiousity, what does RedHat prints with "ps --version" and what's the value of the already said variables?
Here's the Slack 10.2 box:
Code:
root@machine:~# ps --version
procps version 3.2.5
And here's the RedHat box:
Code:
[tva@redhat-box ~]$ ps --version
procps version 3.2.3
As for the "Sl+" only being shown for BSD, I see that in the man page, but I'm not convinced that it is correct. I checked the PS_PERSONALITY and CMD_ENV variables under RedHat and they're not set.

From the man page:
For BSD formats and when the stat keyword is used...

That tells me that it's not only limited to the BSD formats. But even when specifying the 'stat' keyword the output does not show the l-flag ot the +-flag.

I also tried setting the PS_PERSONALITY and CMD_ENV to bsd under Slack 10.2, but the output still shows all the threads.

You refer to PERSONALITY_PS all the time, but the man page says one should set PS_PERSONALITY. Which one did you use?

Quote:
Maybe you should set this variable in your .profile or the system-wide /etc/profile if you want the same behaviour than RedHat...
Immm... but it doesn't work either way, so setting it globally won't help.

I appreciate the insistent help so far! :-)

--deckert
 
Old 06-11-2006, 06:18 AM   #7
deckert
LQ Newbie
 
Registered: Jun 2006
Location: South Africa
Distribution: Slackware
Posts: 7

Original Poster
Rep: Reputation: 0
Hi Tink,
Quote:
Originally Posted by Tinkster
Could you also post an example of what you'd EXPECT to get, or
what DeadRat displays with the same options?
:-) DeadRat indeed. The very reason I switched to Slack (for servers) is because of all the crap that gets installed (and started) with a default install.

I did post an example of what I get on the RedHat box at the end of my post #3 (after the EDIT).

--deckert
 
Old 06-11-2006, 01:19 PM   #8
theoffset
Member
 
Registered: Aug 2005
Location: Guadalajara, Jal, Mexico
Distribution: Slackware Linux
Posts: 211

Rep: Reputation: 31
Quote:
Originally Posted by deckert
Hi,
You get the above on a Slack 10.2 box? Mine doesn't give that error.
I originally tested it in my Slack --current, but just tested in a Slack 10.2 box and it shows the same warning when running "ps -afx"...

Quote:
Did that too and the output remains the same.
Funny, it should output something different... something is definitly wrong...

Quote:
Here's the Slack 10.2 box:
Code:
root@machine:~# ps --version
procps version 3.2.5
And here's the RedHat box:
Code:
[tva@redhat-box ~]$ ps --version
procps version 3.2.3
OK, it looks like they didn't patched ps, so my ramblings where wrong :P

Quote:
You refer to PERSONALITY_PS all the time, but the man page says one should set PS_PERSONALITY. Which one did you use?
Sorry, my fault. It is PS_PERSONALITY

Quote:
Immm... but it doesn't work either way, so setting it globally won't help.

I appreciate the insistent help so far! :-)
Well, I can't tell what's wrong. Your ps isn't showing the warning which is quite weird, and running "ps afx" instead of "ps -afx" doesn't seems to work... I must say that this one beats me

Still, I'm convinced that "ps -afx" is an invalid command (because of the "-x")...

Sorry. I give up.

Just two things: Just run the good 'ol "ps aux"... and Somebody else may know what's wrong??


Good luck.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
"Find all threads started by user" not showing all threads Nylex LQ Suggestions & Feedback 3 12-28-2005 09:28 PM
Seeing all processes with 'ps' pfunk Linux - General 6 03-24-2004 01:34 PM
'ps' Blues Odd_Bloke Linux - Newbie 3 08-30-2003 01:03 AM
Threads showing up as processes on ps command eDubster Linux - General 1 04-28-2003 05:51 PM
Threads showing up as not viewed amp2000 LQ Suggestions & Feedback 1 12-17-2002 12:09 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 10:52 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration