[Toybox] Simplifying (was Re: top -H segfault)

Rob Landley rob at landley.net
Wed Jun 8 18:37:28 PDT 2016


On 06/06/2016 05:33 PM, enh wrote:
> On Mon, Jun 6, 2016 at 12:41 PM, Rob Landley <rob at landley.net> wrote:
>> Too much chatter, let me simplify. (Patch inlined below.)
>>> I checked in a thing,
>>
>> Let me know if that (in current git) is now displaying what you want.
> 
> that gives me enough to replace toolbox top.

Is the patch below better behavior than this, or is this good enough?

> an example that should be unwrapped enough to be legible:
> 
> $ adb shell toybox top -b -n 1 -H -s 6 -o pid,tid,tname,comm | grep adbd
>   PID   TID TNAME                      [COMM]
>   190   192 adbd                        usb ffs open
>   190  2585 adbd                        shell srvc 40
>   190   190 adbd                        adbd
>   190   194 adbd                        <-transport
>   190   193 adbd                        ->transport
> 
> as you can see, TNAME is the process name and COMM is the thread name.
> (this is true of how any Linux libc implements thread names.)

TNAME is argv[0] of $PID, COMM is stat[2]

I'm guessing you _do_ want the below patch...? Maybe?

> but, yeah, since "NAME" is a non-standard extension added for Android
> compatibility anyway, NAME makes sense too :-)

And rename to NAME. Ok...?

>>>>  1939  1939 root     20   0  0.0 S      0     0  fg
>>>>          kworker/0:3
>>>
>>> You're showing me what it _is_ doing, not what you want. Let me try to
>>> guess what you want.
>>>
>>> In this case pid==tid, so... you want TNAME to show argv[0] of the
>>> current process in that case? Maybe?
>>>
>>> Something like the attached patch, maybe?
>>
>> Here is the patch making a second guess at what you want. It's on
>> top of current git (the above "is this what you want"), and changes
>> the TNAME behavior to "Show parent argv[0]. If that's blank, show
>> our argv[0]. If that's blank, show [stat2]."
>>
>> That way threads show their parents, parents show themselves, and
>> kernel threads show the [stat2] name. Is this what you want?
> 
> yeah, as far as i can tell this is right.

Ok, I'll apply it then.

Rob



More information about the Toybox mailing list