Bug 4826

Summary: If 'args' is specified as a column name to 'ps -o', any column names given after args are ignored
Product: Busybox Reporter: Dan Nye <dan>
Component: OtherAssignee: unassigned
Status: RESOLVED WONTFIX    
Severity: normal CC: busybox-cvs, dan
Priority: P5    
Version: 1.19.x   
Target Milestone: ---   
Hardware: Macintosh   
OS: Mac OS   
Host: Target:
Build:

Description Dan Nye 2012-03-01 01:56:48 UTC
According to the help text when typing 'ps -o meh', supported column names are: 

user,group,comm,args,pid,ppid,pgid,tty,vsz,stat,rss

These can be specified in any order or combination and work correctly, EXCEPT when 'args' is specified as a column name. When this is done, no column names given after it will be shown.

So, typing 'ps -o user,group,comm,pid,ppid,pgid,tty,vsz,stat,rss,args' will show all columns, as 'args' is last in the list. However, re-ordering the same parameters so 'args' comes earlier will break. For example, 'ps -o user,group,args,comm,pid,ppid,pgid,tty,vsz,stat,rss' will show only the user,group, and args columns.

The placement doesn't matter... whatever comes after 'args' fails to get shown. 

Incidentally, the same holds true even when specifying the -o parameter multiple times. This shows 3 columns, user, group, and args:

ps -o user -o group -o args

Whereas this shows only the args column:

ps -o args -o user -o group

I'm running BusyBox v1.19.3 (2012-02-21 15:37:53 WET) multi-call binary on my D-Link DNS-323 NAS box.
Comment 1 Denys Vlasenko 2012-03-01 07:04:56 UTC
> Whereas this shows only the args column:
> 
> ps -o args -o user -o group

This is caused by the large width of args column by default - it is 2048 chars. The total width of ps output is capped by the same value, therefore any columns after args are never visible - they are truncated.

Try this:

ps -o args=ARGS.................. -o user -o group

This will specify the header, and therefore the width of args column to be less than the default.
Comment 2 Dan Nye 2012-03-01 09:44:35 UTC
(In reply to comment #1)
> > Whereas this shows only the args column:
> > 
> > ps -o args -o user -o group
> 
> This is caused by the large width of args column by default - it is 2048 chars.
> The total width of ps output is capped by the same value, therefore any columns
> after args are never visible - they are truncated.
> 
> Try this:
> 
> ps -o args=ARGS.................. -o user -o group
> 
> This will specify the header, and therefore the width of args column to be less
> than the default.

That works a treat, thanks, and has also helped me to understand why this didn't work for me earlier:

ps -o user,args=aheading,group

I guess people might want to put commas in column headers, and so this is unlikely to change :-)

I guess my only suggestions would be:

1) Update the list of strings returned by 'ps -o meh' to put 'args' at the end. This would avoid people unfamiliar with the situation spending a long time trying to work out why the list of columns they've copied and pasted verbatim fails to show all the columns that the help text says it supports

2) Update the 'usage' screen for ps to show this list. Due to size limitations, many BusyBox installations lack a manual. It was only after giving for the supported commands that I took a guess, got it wrong, and then got the help text.

3) Why not update the default column width for 'args' to be less than the width of the terminal, assuming the output is printed to the screen?

Thanks for clearing the mystery up for me :-)
Comment 3 Denys Vlasenko 2014-02-27 12:34:11 UTC
(In reply to comment #2)
> 3) Why not update the default column width for 'args' to be less than the width
> of the terminal, assuming the output is printed to the screen?

Because a simple cmd like "ps -o args" would show less information than it can.
Now it is optimal: it uses entire screen width.