Age | Commit message (Collapse) | Author |
|
|
|
|
|
|
|
(resulting in 400% CPU with 4 threads), and add a couple comments.
|
|
|
|
We hadn't updated the output in -b mode ever since I broke this in 2016.
Bug: http://b/126347053 "top doesn't seem to update the output when run in batch mode (-b)"
|
|
Linux has more states than we were giving it credit for, which led to
our numbers not adding up. Since the exact details seem to change
between versions, and since having code specific to each kernel version
is unattractive, go with the heuristic that there are relatively fewer
"stopped" states (and they change less frequently), so all unknowns are
"sleeping".
|
|
|
|
|
|
This also makes everything more readable by separating out the -b no
formatting case.
The whitespace trimming for -b isn't strictly necessary, but it looks
weird if we output unnecessary spaces at the end of the line in -b mode,
and we've fixed it before, so let's not regress here. It also seems more
logical to do this in the one place where it actually happens.
|
|
Both refresh the display in the traditional implementation.
|
|
Even phones have enough RAM these days that KiB is not a reasonable
unit. Traditional top always uses MiB instead of always using KiB, but
we may as well just let human_readable pick a unit (that way if KiB is
reasonable on your box, that's what you'll get).
Before:
Tasks: 967 total, 1 running, 581 sleeping, 0 stopped, 0 zombie
Mem: 196734820k total,183891564k used, 12843256k free, 5805008k buffers
Swap:199888892k total, 719104k used,199169788k free,130367280k cached
After:
Tasks: 965 total, 2 running, 577 sleeping, 0 stopped, 0 zombie
Mem: 188G total, 175G used, 13G free, 5.5G buffers
Swap: 191G total, 702M used, 190G free, 124G cached
|
|
Matches traditional top.
|
|
|
|
|
|
If table grows >64 entries XX needs to change, but it can't be 128 yet
because the slot value is a signed char. Currently 59 entries in table...
|
|
|
|
Be consistent about upper versus lower case. (Upper seems to have the
majority, so I went with that, though I'm happy to provide the opposite
patch as long as we're consistent!)
Be consistent about using \t. (Though saving a few bytes seems like it
might be better done in the code that generates help.h rather than
directly in the source, since tabs make careful ASCII art layout hard
enough that we regularly have things misaligned.)
Remove trailing periods (most of which seem to have been added by me).
Always use the US "human readable" rather than my British
"human-readable", and be more consistent about declaring whether we're
showing multiples of 1000 or 1024.
Just say "verbose" rather than adding a useless "mode" or "output".
|
|
|
|
Even if we don't build ps, we can't have a Linux-only struct in GLOBALS.
The obvious alternative to this would be to have a fake struct sysinfo
in lib/portability.h. Since having a real macOS replacement for
sysinfo(2) seems unlikely at this point, I went this route instead.
|
|
xparsetime() not to need floating point, adjust callers.
|
|
|
|
|
|
|
|
|
|
add comments to get_ps().
|
|
|
|
|
|
|
|
LTP uses `top -d 0.1`, which isn't convincingly useful, but general
support for other time units might be useful, and switching to xparsetime
addresses both at once.
Also fix 3169d948c049664bcf7216d4c4ae751881099d3e where I mistakenly
treated `rev` and `toys.optflags&FLAG_b` as interchangeable. (Without
this second fix, `top -b` looks fine but `top` is broken!)
Also fix xparsetime to reject input such as "monkey" or "1monkey".
|
|
|
|
(Otherwise updating pid to parents makes threads read thread parent data.)
|
|
The first contains display fields selectable by the -o argument,
the second contains the /proc/$PID data for one process.
|
|
(Bionic _does_ do the malloc(0)!=0 thing, the problem is pedantic access
checking, not null dereference. So test count instead.)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
iotop -H
|
|
out from under us due to asyncronous process exit.
The directory we're traversing vanishing can result in DIRTREE_ABORTVAL
being returned, which we turn into a NUL entry, but then we were trying to
look at that null entry's children. Oops.
|
|
the help infrastructure to handle it.
(The lifetime rules are all wrong for hunks that get reused. Needs a largeish
rewrite.)
|
|
`ps -A | cat` shouldn't have different output depending on the size of
your terminal window.
|
|
exist, which can hit ps when /proc isn't there or /proc/$PID/task isn't
there (because process exited between the time we checked its contents
and the time we looked for its threads).
|
|
(Recent "show + for last char when truncated" change broke that, putting it
back.)
|
|
|
|
to be left justified again.
|
|
|
|
when we can't query terminal size pad to 80 but add -w.
|