1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 00:37:35 +00:00

ps: Allow -q option multiple times, and separated by spaces or commas

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`.
This commit is contained in:
Sam Atkins 2023-05-15 14:59:26 +01:00 committed by Andreas Kling
parent a6e701a67b
commit 45c429853a
2 changed files with 33 additions and 21 deletions

View file

@ -18,7 +18,7 @@ For each process, print its PID (process ID), to which TTY it belongs, and invok
* `-a`: Consider all processes that are associated with a TTY.
* `-A` or `-e`: Consider all processes, not just those in the current TTY.
* `-f`: Also print for each process: UID (as resolved username), PPID (parent PID), and STATE (Runnable, Sleeping, Selecting, Reading, etc.)
* `-q pid-list`: Only consider the given PIDs, if they exist.
* `-q pid-list`: Only consider the given PIDs, if they exist. `pid-list` is a list of PIDs, separated by commas or spaces.
## Examples