summaryrefslogtreecommitdiff
path: root/procps/pgrep.c
diff options
context:
space:
mode:
Diffstat (limited to 'procps/pgrep.c')
-rw-r--r--procps/pgrep.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/procps/pgrep.c b/procps/pgrep.c
index 7b3cd8e..0e8e529 100644
--- a/procps/pgrep.c
+++ b/procps/pgrep.c
@@ -111,8 +111,15 @@ int pgrep_main(int argc UNUSED_PARAM, char **argv)
if (proc->pid == pid)
continue;
cmd = proc->argv0;
- if (!cmd)
+ if (!cmd) {
cmd = proc->comm;
+ } else {
+ int i = proc->argv_len;
+ while (i) {
+ if (!cmd[i]) cmd[i] = ' ';
+ i--;
+ }
+ }
/* NB: OPT_INVERT is always 0 or 1 */
if ((regexec(&re_buffer, cmd, 1, re_match, 0) == 0 /* match found */
&& (!OPT_ANCHOR || (re_match[0].rm_so == 0 && re_match[0].rm_eo == (regoff_t)strlen(cmd)))) ^ OPT_INVERT