← Commit list

4ee218a2d

Denys Vlasenko
Denys Vlasenko
2025-11-08
SUCCESS Duration: 157s

Subject

pgrep/pkill: fix -x to also match comm field

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0
gcc -Wp,-MD,applets/.usage.d -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer      -Iinclude -Iinclude -o applets/usage applets/usage.c

Build Log

(log yok)

Commit Diff GitHub →

procps/pgrep.c+4 -4
@@ -215,16 +215,16 @@ int pgrep_main(int argc UNUSED_PARAM, char **argv)
if (!match) {
again:
match = (regexec(&re_buffer, cmd, 1, re_match, 0) == 0);
+ if (match && OPT_ANCHOR) {
+ /* -x requires full string match */
+ match = (re_match[0].rm_so == 0 && cmd[re_match[0].rm_eo] == '\0');
+ }
if (!match && cmd != proc->comm) {
/* if argv[] did not match, try comm */
cmdlen = -1;
cmd = proc->comm;
goto again;
}
- if (match && OPT_ANCHOR) {
- /* -x requires full string match */
- match = (re_match[0].rm_so == 0 && cmd[re_match[0].rm_eo] == '\0');
- }
}
/* NB: OPT_INVERT is always 0 or 1 */