[Toybox] Fun with ps.

enh enh at google.com
Fri Oct 9 15:11:25 PDT 2015


On Fri, Oct 9, 2015 at 2:29 PM, Rob Landley <rob at landley.net> wrote:
> Default ps output gets trunctated to screen width. Unfortunately this is
> a little difficult to demonstrate using the posix options because ps -A
> defaults to -o pid,tty,time,cmd and cmd is just command name not command
> line, but:
>
>   ps -A -o pid,tty,time,command
>
> Demonstrates it reasonably well. This is why -w exists., so "ps -Aw -o
> ..." can produce the full command line output.
>
> However, if I do:
>
> ps -o pid,pid,pid,pid,pid,pid,pid,pid,pid,pid,pid,pid,pid,pid,pid,pid
>
> This happily wraps around the edge of the screen. So what's clipping at
> the right edge is the expansion of the _last_ field, using the special
> last field rules which only apply to left justified fields anyway.
>
> It would be so nice if the posix spec were worth something here. I'm sad
> we haven't got a standards body that can actually explain how any of
> this stuff is supposed to work.
>
> Grrr. Need test suite entries for this, which means the controlled
> environment with known process IDs to run them in. (Well, known-ish
> given that I can't control how many kernel threads the kernel launches
> for random drivers on startup, which changes each kernel version
> "upgrade"...)

or you factor your code so you can write unit tests... formatting code
can be tested independently of the code that actually collects live
data.

> Rob
> _______________________________________________
> Toybox mailing list
> Toybox at lists.landley.net
> http://lists.landley.net/listinfo.cgi/toybox-landley.net



-- 
Elliott Hughes - http://who/enh - http://jessies.org/~enh/
Android native code/tools questions? Mail me/drop by/add me as a reviewer.

 1444428685.0


More information about the Toybox mailing list