top -h doesn't display Thread Names

Denys Vlasenko vda.linux at googlemail.com
Sat Jun 18 13:53:25 UTC 2011


On Friday 17 June 2011 15:06, Daniel Ng wrote:
> 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?

Fixed in git:

http://git.busybox.net/busybox/commit/?id=5331e382f72a606c026424e95fcc7dc50a25608c

Please let me know if this doesn't solve your problem.
-- 
vda


More information about the busybox mailing list