Commit Graph

26 Commits

Author SHA1 Message Date
Sam Atkins
3aff3c610a ps: Add -p option, and distinguish it from -q 2023-05-16 12:54:18 +02:00
Sam Atkins
45c429853a 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`.
2023-05-16 12:54:18 +02:00
Sam Atkins
a6e701a67b ps: Add the -a option, to list all processes associated with terminals 2023-05-16 12:54:18 +02:00
Sam Atkins
afb55d9fd8 ps: Add the -A option
This is identical to our existing `-e` option, but both are required by
POSIX.
2023-05-16 12:54:18 +02:00
Sam Atkins
02ee93d6c9 ps: Use Optional for column indices, instead of -1 meaning "not present" 2023-05-16 12:54:18 +02:00
Sam Atkins
e6f7b828c3 ps: Ensure columns capacity in advance
Also use unchecked_append() in a couple of other places where we can.
2023-05-16 12:54:18 +02:00
Sam Atkins
2b02c58cd3 ps: Migrate from DeprecatedString to String 2023-05-16 12:54:18 +02:00
Sam Atkins
61552415a3 ps: Use Core::System::fstat() 2023-05-16 12:54:18 +02:00
Tim Schumacher
8940f2da7f LibCore: Use Core::Stream for ProcessStatisticsReader 2022-12-10 11:49:24 +00:00
Linus Groh
6e19ab2bbc AK+Everywhere: Rename String to DeprecatedString
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 :^)
2022-12-06 08:54:33 +01:00
Liav A
9d1ba0e6ad Utilities: Use new global variables at /sys/kernel/ directory 2022-10-25 15:33:34 -06:00
Thomas Symalla
77add584fa Userland: Fix crash when inputting non-tty device into ps
This PR aims to fix #13299 by avoiding assertion failure
while trying to determine the pseudo tty when inputting
any non-tty device device into ps.
2022-04-02 21:49:16 +02:00
Liav A
d7c7e6e496 Utilities/ps: Don't assume the kernel can provide real TTY paths 2022-03-26 11:01:49 +01:00
Brian Gianforcaro
cf4fa936be Everywhere: Use default execpromises argument for Core::System::pledge 2021-11-28 08:04:57 +01:00
Andreas Kling
e6579e7029 ps: Port to LibMain :^) 2021-11-23 15:44:59 +01:00
Peter Elliott
7283b0b214 Utilities: Show PGID and SID in ps -f 2021-10-17 22:18:48 +02:00
Mahmoud Mandour
ac7c83689b ps: Sort using input order in case of -q
Now the output of `ps -q <list>` is sorted according to the order the
user specified.
2021-08-28 15:08:00 +04:30
Mahmoud Mandour
259ecb3d11 ps: Select specific processes by their PIDs
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.
2021-08-28 15:08:00 +04:30
Tom
7e77a2ec40 Everywhere: Improve CPU usage calculation
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
2021-07-18 22:08:26 +02:00
Gunnar Beutner
bc174b0fd0 Utilities: Make sure columns for ps are properly aligned
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".
2021-06-03 17:53:59 +02:00
Linus Groh
f5c35fccca Userland: Replace most printf-style APIs with AK::Format APIs :^) 2021-06-01 21:30:16 +01:00
Linus Groh
1eb048bed0 Userland: Remove a bunch of unused includes
As reported by CLion.
2021-05-31 18:01:53 +01:00
Andreas Kling
873eb47d2b ps: Sort output by PID :^) 2021-05-23 11:26:19 +02:00
Andreas Kling
a1e133cc6b LibCore: Make ProcessStatisticsReader return results in a Vector
The HashMap API was overkill and made using this less ergonomic than
it should be.
2021-05-23 11:10:15 +02:00
Brian Gianforcaro
1682f0b760 Everything: Move to SPDX license identifiers in all files.
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 *
2021-04-22 11:22:27 +02:00
Andreas Kling
ececac65c2 Userland: Move command-line utilities to Userland/Utilities/ 2021-01-12 12:04:09 +01:00