Unify matching logic in pgrep and pkill#321
Merged
cakebaker merged 6 commits intouutils:mainfrom Feb 13, 2025
Merged
Conversation
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.
f335d85 to
5ba8e29
Compare
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.
5ba8e29 to
68007a7
Compare
cakebaker
reviewed
Feb 12, 2025
cakebaker
reviewed
Feb 12, 2025
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
68007a7 to
f946eb6
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #321 +/- ##
===========================
===========================
☔ View full report in Codecov by Sentry. |
Contributor
|
Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.