top -h doesn't display Thread Names

Daniel Ng daniel.ng1234 at gmail.com
Fri Jun 17 13:06:01 UTC 2011


Hi,

I've noticed a bug with busybox's 'top' command-

When the 'display threads' option is enabled with the '-h' parameter, the 
individual thread names should be displayed in the 'COMMAND' column, in place 
of arg0. 
This is how the standard version of top behaves.

The current busybox code results in only arg0 being displayed. 
Hence, for multiple threads spawned under the one process, only the process' 
arg0 entry will show in the 'COMMAND' column for each thread. 
The multiple threads would be displayed, but you can't easily tell which 
thread is which because their displayed COMMAND is the same arg0.

ie.-

Say you have an executable called 'myProgram' that spawns 4 threads.

The current incorrect behaviour of 'top':

COMMAND
myProgram
myProgram
myProgram
myProgram

vs. what it should be:

COMMAND
myThread1
myThread2
myThread3
myThread4

The root cause is that read_cmdline() is used to display the COMMAND column, 
regardless of whether the '-h' option is set.

Unfortunately, read_cmdline() is called by display_process_list(). This 
function doesn't know if the '-h' option was set.

The only solution I can think of is to change the parameters of 
display_process_list() so that it knows if '-h' was set.

However, this feels like a bit of a hack, just to deal with this special case.

Can anyone suggest a better soultion?

Cheers,
Daniel




More information about the busybox mailing list