diff options
Diffstat (limited to 'procps')
| -rw-r--r-- | procps/pgrep.c | 9 | ||||
| -rw-r--r-- | procps/pidof.c | 4 |
2 files changed, 9 insertions, 4 deletions
diff --git a/procps/pgrep.c b/procps/pgrep.c index 7b3cd8e50..0e8e5294e 100644 --- a/procps/pgrep.c +++ b/procps/pgrep.c | |||
| @@ -111,8 +111,15 @@ int pgrep_main(int argc UNUSED_PARAM, char **argv) | |||
| 111 | if (proc->pid == pid) | 111 | if (proc->pid == pid) |
| 112 | continue; | 112 | continue; |
| 113 | cmd = proc->argv0; | 113 | cmd = proc->argv0; |
| 114 | if (!cmd) | 114 | if (!cmd) { |
| 115 | cmd = proc->comm; | 115 | cmd = proc->comm; |
| 116 | } else { | ||
| 117 | int i = proc->argv_len; | ||
| 118 | while (i) { | ||
| 119 | if (!cmd[i]) cmd[i] = ' '; | ||
| 120 | i--; | ||
| 121 | } | ||
| 122 | } | ||
| 116 | /* NB: OPT_INVERT is always 0 or 1 */ | 123 | /* NB: OPT_INVERT is always 0 or 1 */ |
| 117 | if ((regexec(&re_buffer, cmd, 1, re_match, 0) == 0 /* match found */ | 124 | if ((regexec(&re_buffer, cmd, 1, re_match, 0) == 0 /* match found */ |
| 118 | && (!OPT_ANCHOR || (re_match[0].rm_so == 0 && re_match[0].rm_eo == (regoff_t)strlen(cmd)))) ^ OPT_INVERT | 125 | && (!OPT_ANCHOR || (re_match[0].rm_so == 0 && re_match[0].rm_eo == (regoff_t)strlen(cmd)))) ^ OPT_INVERT |
diff --git a/procps/pidof.c b/procps/pidof.c index 2519473e8..780504433 100644 --- a/procps/pidof.c +++ b/procps/pidof.c | |||
| @@ -22,7 +22,6 @@ int pidof_main(int argc UNUSED_PARAM, char **argv) | |||
| 22 | unsigned first = 1; | 22 | unsigned first = 1; |
| 23 | unsigned opt; | 23 | unsigned opt; |
| 24 | #if ENABLE_FEATURE_PIDOF_OMIT | 24 | #if ENABLE_FEATURE_PIDOF_OMIT |
| 25 | char ppid_str[sizeof(int)*3 + 1]; | ||
| 26 | llist_t *omits = NULL; /* list of pids to omit */ | 25 | llist_t *omits = NULL; /* list of pids to omit */ |
| 27 | opt_complementary = "o::"; | 26 | opt_complementary = "o::"; |
| 28 | #endif | 27 | #endif |
| @@ -39,8 +38,7 @@ int pidof_main(int argc UNUSED_PARAM, char **argv) | |||
| 39 | while (omits_p) { | 38 | while (omits_p) { |
| 40 | /* are we asked to exclude the parent's process ID? */ | 39 | /* are we asked to exclude the parent's process ID? */ |
| 41 | if (strcmp(omits_p->data, "%PPID") == 0) { | 40 | if (strcmp(omits_p->data, "%PPID") == 0) { |
| 42 | sprintf(ppid_str, "%u", (unsigned)getppid()); | 41 | omits_p->data = utoa((unsigned)getppid()); |
| 43 | omits_p->data = ppid_str; | ||
| 44 | } | 42 | } |
| 45 | omits_p = omits_p->link; | 43 | omits_p = omits_p->link; |
| 46 | } | 44 | } |
