215 Commits

Author SHA1 Message Date
Daniel Hofstetter f3d07da42f Merge pull request #367 from Bluemangoo/feature/vmstat
vmstat: add basic implementation of `vmstat`
2025-03-31 16:58:00 +02:00
estodi 35dad8d767 pmap: fixed to hide the header when permission is denied (#378)
* pmap: fixed to hide the header when permission is denied

* pmap: fixed lint error
2025-03-30 18:39:07 +02:00
estodi f635788852 pmap: implement --extended (#368)
* add inode in MapLine

inode information is used by extended options

* pmap: implement extended option

* formatted files

* updated test_pmap.rs

* fixed lint errors

* fixed missing fields and typo

* fixed parse_smap_entries algorithm
removed a redundant field

* pmap: fixed `parse_smap_entries` algorithm
to improve its endurance against platform variations

* pmap: fixed typo

* Update src/uu/pmap/src/smaps_format_parser.rs

Incorporate the suggested change

Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>

---------

Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
2025-03-29 15:09:38 +01:00
Bluemangoo b5f44f3fa1 vmstat: add simple tests 2025-03-28 16:14:09 +00:00
Tuomas Tynkkynen 191b10a95e pidof: Implement '-x' flag 2025-03-27 20:12:40 +02:00
Krysztal Huang 1d83d7a8a3 tload: Basic implementation of tload (#362)
* tload: add basic tui layout of modern look

* tload: set x-axis bound from 0 to the width of terminal

* tload: fix mismatched returning type

* tload: add `#[allow(clippy::cognitive_complexity)]`

* tload: add by-utils test

* tload: tweaks for max height of chart

* tload: bump version of `ratatui` from `0.28` to `0.29`

* tload: fix typo

* tload: set exit code to 130

* tload: fix typo

* tload: add license header for `tui.rs`
2025-03-25 16:58:35 +01:00
Tuomas Tynkkynen 9fb6aa3be5 pidof: Implement --with-workers
Lots of tests rely on finding kthreadd thus -w flag needs to be added
to them.
2025-03-24 18:46:17 +02:00
Krysztal Huang 76fb2a55d7 Merge pull request #360 from dezgeg/require-handler-fixes
pgrep/pkill/pidwait: --require-handler fixes
2025-03-24 10:16:20 +08:00
Tuomas Tynkkynen eb0871abc7 process_matcher: Allow lone --require-handler option
Make it possible to run `pgrep --require-handler` without any other
matcher arguments.
2025-03-23 21:21:50 +02:00
Tuomas Tynkkynen 11584c8f53 process_matcher: Fix off-by-one in signal mask
Apparently the signal masks in /proc/status are off-by-one, ie. bit 0
represents signal 1. In original pgrep signal 0 results in matching
signal 64 so replicate this behaviour also.
2025-03-23 21:16:55 +02:00
Daniel Hofstetter 5ca17df66a pidof: rename test & remove target_os cfg 2025-03-21 10:58:07 +01:00
Daniel Hofstetter 05fcfdcaef pidof: don't require program name as arg 2025-03-21 10:55:59 +01:00
Daniel Hofstetter 92d674b3b2 pidof: disable "test_find_init", as it fails in CI 2025-03-20 09:31:42 +01:00
Tuomas Tynkkynen 8b64351362 pgrep: Support -w option
Unlike pidof's similar option, the pgrep version will run the match
predicates against every thread of the system and printing matching
tids (unlike pidof which will run match predicates on every process of
the system and then list every thread of every matched process).
2025-02-28 23:33:47 +02:00
Tuomas Tynkkynen 6dd29c59b8 process_matcher: Add support for --pgroup and --session 2025-02-27 02:13:47 +02:00
Tuomas Tynkkynen 9e28ec2bf7 test_pgrep: Remove accidentally left debug print 2025-02-27 01:42:22 +02:00
Tuomas Tynkkynen 16b5cc2464 process_matcher: Don't match own procps process
For example, pgrep should never report itself as a match (but it can
match other pgrep processes).
2025-02-26 17:28:08 +02:00
Tuomas Tynkkynen 36a9cfb4fa process_matcher: Add support for --uid, --euid & --group
Resolving user/group names requires enabling "entries" feature in
uucore.
2025-02-23 03:53:54 +02:00
Daniel Hofstetter a044ad43d4 pgrep: don't show msg if pattern is 15 chars long 2025-02-19 09:21:41 +01:00
Tuomas Tynkkynen 43f7412e74 process_matcher: Fix accidentally matching against pid
Currently pgrep/pkill without -x/-f flags is matching based on the first
15 characters of /proc/<pid>/stat, which actually contains something like
"1116878 (cat) R" thus matching the process id when it should just match
on the name.

This has probably come from misunderstanding the comment from manpage:

> The process name used for matching is limited to the 15 characters
> present in the output of /proc/pid/stat.

... which doesn't mean pgrep/pkill is literally matching on 15
characters of /proc/<pid>/stat but that the process name in that file is
truncated to 15 characters.

Fixes #307
2025-02-19 01:48:41 +02:00
Krysztal Huang a2d49d6d03 Merge pull request #323 from dezgeg/pgrep_pkill_unification3
pidwait: Use common process_matcher (+ move a pidwait feature there)
2025-02-18 15:28:37 +08:00
Tuomas Tynkkynen 74a2ffdddf pgrep, pkill: Add check for pattern length
pidwait already has a check for this, copy it to the common
process_matcher implementation.

Some tests need adjustment to not use such long fake names.
2025-02-17 18:46:14 +02:00
Tuomas Tynkkynen 967d288d8b pidof: Support '-t' flag
This flag makes pidof print thread ids of threads belonging to the
matching processes.
2025-02-17 18:38:52 +02:00
Tuomas Tynkkynen f946eb6450 pgrep: Support --signal and --require-handler
This is not listed in pgrep --help, but is documented in the man page
and does work. Unlike pkill the -SIGNAL short option is not supported by
pgrep.

Simplify parse_signal_value with ok_or_else
2025-02-12 20:24:50 +02:00
Tuomas Tynkkynen cfe4cb337e pkill: Support --inverse
pkill --help doesn't list this option, but it is listed in the manpage
(and does work). Unlike pgrep, the short option '-v' doesn't exists for
pkill though.
2025-02-11 23:52:53 +02:00