summaryrefslogtreecommitdiff
path: root/libbb/find_pid_by_name.c
diff options
context:
space:
mode:
authorDenis Vlasenko2006-11-05 00:43:51 +0000
committerDenis Vlasenko2006-11-05 00:43:51 +0000
commit459e4d6cf77940977a064edab60c7162731554fb (patch)
tree5deb7d2b82c280440761cceb4281738867d5631a /libbb/find_pid_by_name.c
parentfa07680091d20f9da1f8fa2c145dd92b5d62ae09 (diff)
downloadbusybox-459e4d6cf77940977a064edab60c7162731554fb.zip
busybox-459e4d6cf77940977a064edab60c7162731554fb.tar.gz
replace /proc scanning code by more versatile one.
Use it where appropriate. Stop scanning /etc/passwd *for every process*!!! (uid->username) top: reduce memory usage - we won't save unneeded fields from /proc info anymore. Downside: ~+250 bytes of code
Diffstat (limited to 'libbb/find_pid_by_name.c')
-rw-r--r--libbb/find_pid_by_name.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/libbb/find_pid_by_name.c b/libbb/find_pid_by_name.c
index 05f7f96..e986169 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)
{
pid_t* pidList;
int i = 0;
- procps_status_t* p;
+ procps_status_t* p = NULL;
pidList = xmalloc(sizeof(*pidList));
- while ((p = procps_scan(0)) != 0) {
- if (strncmp(p->short_cmd, procName, COMM_LEN-1) == 0) {
+ while ((p = procps_scan(p, PSSCAN_PID|PSSCAN_COMM))) {
+ if (strncmp(p->comm, procName, sizeof(p->comm)-1) == 0) {
pidList = xrealloc(pidList, sizeof(*pidList) * (i+2));
pidList[i++] = p->pid;
}