Just like on Linux, we can easily print the process creation time. The
format of a printed time is either "hour:minute" if the process started
today, or "short_month_name:day_of_the_month" (for example, "Aug26").
This option allows the user to change which colums are displayed
by giving comma or space separated list of column format specifiers.
A column format specifier is of the form: `COLUMN_NAME[=COLUMN_TITLE]`.
Where `COLUMN_NAME` is any of: uid, pid, ppid, pgid, sid, state, tty,
or cmd. Specifying a `COLUMN_TITLE` will change the name shown in the
column header.
`COLUMN_TITLE` may be blank. If all given column titles
are blank, the header is omitted.
This fixes a logic bug which allowed processes not specified by the
user to be selected when the `-q` option was used. This caused the
program to crash when sorting processes into the correct order.
Previously, it was assumed that only one filtering option, such as
`-u` or `-p` would be used at a time. With this PR, processes are now
shown if they match any of the specified filters.
Previously we did some of the filtering before the loop, and some inside
it, which made things awkward to reason about. This also lets us avoid
generating a TTY string for each process unless there's a column for it.
Several differences here:
- Passing `-q` multiple times will add them together, instead of the
last one overwriting the previous ones.
- `-q` PIDs can be separated by commas as well as spaces.
- We check that the PIDs are integers while parsing the arguments,
instead of later on.
The "parse a list of things as an option" is extracted into a helper
function, because we're going to want the same logic for `-g`, `-G`,
`-p`, `-t`, `-u`, and `-U`.
We have a new, improved string type coming up in AK (OOM aware, no null
state), and while it's going to use UTF-8, the name UTF8String is a
mouthful - so let's free up the String name by renaming the existing
class.
Making the old one have an annoying name will hopefully also help with
quick adoption :^)
This adds a `-q` option, which expects a comma-separated list of PIDs as
a value. On using it, only the processes associated with the supplied
PIDs are output.
As threads come and go, we can't simply account for how many time
slices the threads at any given point may have been using. We need to
also account for threads that have since disappeared. This means we
also need to track how many time slices we have expired globally.
However, because this doesn't account for context switches outside of
the system timer tick values may still be under-reported. To solve this
we will need to track more accurate time information on each context
switch.
This also fixes top's cpu usage calculation which was still based on
the number of context switches.
Fixes#6473
This updates ps so that it calculates the ideal column width instead
of relying on hard-coded values. Previously the STATE column was too
small to fit the state for "FinalizerTask".
SPDX License Identifiers are a more compact / standardized
way of representing file license information.
See: https://spdx.dev/resources/use/#identifiers
This was done with the `ambr` search and replace tool.
ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *