diff options
Diffstat (limited to 'libbb/find_pid_by_name.c')
-rw-r--r-- | libbb/find_pid_by_name.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/libbb/find_pid_by_name.c b/libbb/find_pid_by_name.c index 05f7f968f..e98616940 100644 --- a/libbb/find_pid_by_name.c +++ b/libbb/find_pid_by_name.c | |||
@@ -23,11 +23,11 @@ pid_t* find_pid_by_name(const char* procName) | |||
23 | { | 23 | { |
24 | pid_t* pidList; | 24 | pid_t* pidList; |
25 | int i = 0; | 25 | int i = 0; |
26 | procps_status_t* p; | 26 | procps_status_t* p = NULL; |
27 | 27 | ||
28 | pidList = xmalloc(sizeof(*pidList)); | 28 | pidList = xmalloc(sizeof(*pidList)); |
29 | while ((p = procps_scan(0)) != 0) { | 29 | while ((p = procps_scan(p, PSSCAN_PID|PSSCAN_COMM))) { |
30 | if (strncmp(p->short_cmd, procName, COMM_LEN-1) == 0) { | 30 | if (strncmp(p->comm, procName, sizeof(p->comm)-1) == 0) { |
31 | pidList = xrealloc(pidList, sizeof(*pidList) * (i+2)); | 31 | pidList = xrealloc(pidList, sizeof(*pidList) * (i+2)); |
32 | pidList[i++] = p->pid; | 32 | pidList[i++] = p->pid; |
33 | } | 33 | } |