[Toybox] ps and top (and Android)

Rob Landley rob at landley.net
Tue May 3 00:13:03 PDT 2016


Blah, had this window open for a couple days because it represents todo
items, but Tokyo is REALLY DISTRACTING and I'm so busy I haven't done
any of them. I should just send it...

On 04/30/2016 12:53 PM, enh wrote:
> as for top, i think once my pcy patch (or something like it) is in,
> that's almost there too...
> 
> * the TOP_COMMON help isn't getting included in "top --help".

Yeah I need to do a pass on the help infrastructure.

> * no -H to work on threads rather than processes.

Just haven't wired it up yet. :)

> * (probably related to this, -O tcnt shows all 0s.)

Hmmm, it should be checking the bit patterns of used commands and
fetching when (TT.bits&_PS_TCNT) is set. Possibly my top field parsing
isn't setting TT.bits right?

Top needs ps -O so this is easier to test. Hmmm, ubuntu's top has -O
print available field names, and our top should say "all ps -O fields
are available, see ps --help for the full list."

> * no -O pcy, but thanks to sharing we'll get that for free from ps.
> 
> * the Android top had a -m N option to only show the top N. i think
> this was a bad idea (because interactively we should query the
> terminal, and the only batch mode usage i know of is when collecting a
> bugreport and in N that's a zip rather than one long text file, so i
> don't think there's any reason not to just include everything now ---
> "top n" seems pretty bogus anyway; you're probably more interested in
> "anything greater than V in column C"). so unless you think this is a
> good idea, i'd rather see if anyone notices and has a good reason to
> add this. (there's some argument that "i can't just use head because
> of the header", but that's a fixed number of lines and/or you can
> supply -q if you don't want the header at all.)

Agreed. (I have a script that parses top output, and it uses head.
Although you can do an awful lot with ps -k, you only need top if it has
to collage information over two passes of ps at a fixed interval.)

> * speaking of headers, trying to find problems before they find me i
> did find a couple of uses in the tree of GNU ps' --no-headers option.
> obviously they're in scripts meant for the host, but i thought you
> might be interested anyway.

Eh, we have --longopt support if you want to add that as an alias for -q
have at. (Waiting for a user to show up doesn't mean I resist when they do.)

In my Aboriginal Linux project, I build the same set of toybox+busybox
commands for the host as I'm installing on the target, and then I run
the build with the $PATH set to that directory. That way I'm taking
control of my prerequisites and only the "airlock step" of building the
host tools (and symlinking the half-dozen files I _do_ need out of the
host, like gcc, into the new path) depends on the whatever strange stuff
your distro du jour has. (And then I have an environment variable
whitelist and so on...)

But anyway, it's likely at some point in the future when I start
dismantling AOSP and trying to clean it up (I.E. the next big project
after toybox: make AOSP build under android, _and_ try to break it down
into smaller pieces so it can be a modular build with understandable
dependencies and staged prerequisites and so on)... anyway at that
point, I'd probably want to pull the same trick of building toybox and
such for the host and running the rest of the build under it. (Our build
requires the "awk --fruitbasket" option we invented last week? No problem!)

That's post-1.0 though. Feature creep shouldn't move goalposts.

Rob



More information about the Toybox mailing list