Skip to content

Unify matching logic in pgrep and pkill#321

Merged
cakebaker merged 6 commits intouutils:mainfrom
dezgeg:pgrep_pkill_unification
Feb 13, 2025
Merged

Unify matching logic in pgrep and pkill#321
cakebaker merged 6 commits intouutils:mainfrom
dezgeg:pgrep_pkill_unification

Conversation

@dezgeg
Copy link
Copy Markdown
Contributor

@dezgeg dezgeg commented Feb 11, 2025

Currently pgrep and pkill implement slightly different set command line args for process matching, even though both commands should support the same features. This PR extends the functionality of both tools to their superset of features. This will allow deduplicating the process matching part into a common module in a future PR.

Most of the process matching arguments are same between pkill and pgrep.
Currently pgrep has more complete list of possible arguments (with
proper types), so copy over the improvements to pgrep.

However, leave arg!()s that are actually not implemented commented out,
so it's easier to see what the uutils version actually supports.
@dezgeg dezgeg force-pushed the pgrep_pkill_unification branch from f335d85 to 5ba8e29 Compare February 11, 2025 21:50
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.
Translate short signal options like '-TERM' to '--signal=TERM' to simplify
the code and also properly handle the case where both short and long
form is used at the same time.

Change parsing of the SigCgt field to use u64, as there are more than 32
signals.
@dezgeg dezgeg force-pushed the pgrep_pkill_unification branch from 5ba8e29 to 68007a7 Compare February 11, 2025 21:55
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
@dezgeg dezgeg force-pushed the pgrep_pkill_unification branch from 68007a7 to f946eb6 Compare February 12, 2025 18:25
@cakebaker cakebaker merged commit 7f610a2 into uutils:main Feb 13, 2025
14 checks passed
@codecov
Copy link
Copy Markdown

codecov bot commented Feb 13, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 0.00%. Comparing base (6697d2d) to head (a1ef871).
Report is 16 commits behind head on main.

Additional details and impacted files
@@     Coverage Diff     @@
##   main   #321   +/-   ##
===========================
===========================

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@cakebaker
Copy link
Copy Markdown
Contributor

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants