[Toybox] [PATCH] Fix the ps -o CMD vs COMM distinction.

enh enh at google.com
Mon Nov 2 10:51:45 PST 2015


On Mon, Nov 2, 2015 at 12:11 AM, Rob Landley <rob at landley.net> wrote:
> On 10/31/2015 04:02 PM, enh wrote:
>> Better for _me_ would be to change the current code that rewrites
>> characters < ' ' to leave '\0' alone if we're not supposed to be
>> outputting the arguments, but then toybox would match the Android
>> behavior (modulo the fact that we called this field NAME) rather than
>> the usual GNU behavior.
>
> Is this another documented deviation from posix in the big comment block
> near the top, or did I miss a curve?

you mention one wart in this family:

 * It also says that -o "args" and "comm" should behave differently but use
 * the same title, which is not the same title as the default output. (No.)

but NAME is an Android invention. it's basically "imagine if -o comm
worked right and didn't truncate regardless of width". (and we've
never had -o, so it's the only one of the args/cmd/comm/command family
in use on Android.)

>> Does anyone actually want the GNU truncating
>> behavior? cmd/comm/command seems such a mess that although I wouldn't
>> normally suggest adding new stuff, maybe just ignoring all this and
>> adding a NAME field isn't such a bad idea after all...
>
> I have no objection. The old posix default values are kinda nuts these days.
>
> I still have a todo item to switch -l's fields to the ps -ly variant
> (our variant of addr is so long there's a blank line between the header
> and the first ps line and cmd has 3 chars to work with), except... the
> ps -ly variant still has C for no readily apparent reason? That's a
> field I didn't even bother to document because it's kind of sad. Posix
> says "processor utilization for scheduling" with no further
> clarification. (That's why I haven't implemented it yet, hence printing
> a dash.)
>
> The ps man page has it as an alias for -o pcpu only it's just the
> integer part, no fraction. You'll be happy to know that pcpu is
> percentage of processor ticks this process has used since its inception,
> I.E. percentage of CPU (one processor) it could have used on an idle
> system if it was constantly cpu bound the entire time _and_ the system
> was never suspended (because elapsed time continues to tick when the
> machine's off...).
>
> Currently on my box I have five processes that don't have a zero here:
> Three with a 1 and two with a 2, and one of each of those is chromium
> (_that's_ how bad a cpu hog you have to be to show up here).
>
> How any of that is usable "for scheduling", I couldn't tell you, since
> it's all historical usage of long-running processes telling you about
> what they did last week...

Android has an unrelated non-standard set of scheduling-related
fields, but i was worrying about the portable stuff first. (i didn't
actually realize that -o comm was broken until working on this. i
thought our only deviation there was that we had a different name for
the field.)

> Anyway, I ripped out the crazy bitmap stuff and redid the default/-f/-l
> command line parsing as strings so it would be easy to change 'em. If
> you have a better idea what they should be, now's the time to speak up.
> (Heck, I've got a CFG_TOYBOX_ANDROID symbol, easy enough to change the
> default just for that, if you've got a userbase that'll care.)

yeah, as far as i can tell from the internal tree basically 99%
existing use of Android's ps is just "ps" and then
grepping/sedding/parsing the result.

> Also, on a previous patch: having --ppid like that in the help text is
> really ugly. Can we define -P as the short version of this so the help
> text doesn't mix longopts with shortopts? (Keeping the long alias for
> compatability with existing users, fine. Nothing seems to be using -P
> yet...)

i did think it odd that GNU didn't have a short option for this
(unless they're just wary of stepping on future POSIX's toes), but
given that --ppid is the portable option i think that's the better
thing to have in the help text.

(i'm not as anti-longopt as you in general. especially for rarely-used
functionality it's a lot easier to remember the longopt.)

> I'm trying to cut a release in the next day or two, so getting this
> nailed down would be nice...

iirc, ps -C is the only standard thing that Android had an equivalent
of (with different syntax, of course).

i think switching Android's ps over is going to be hard because it's
always been very different from regular ps *and* it's very heavily
used. i wouldn't block a release on that!

> Thanks,
>
> Rob



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

 1446490305.0


More information about the Toybox mailing list