aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorandersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277>2001-06-26 22:44:09 +0000
committerandersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277>2001-06-26 22:44:09 +0000
commitc97b9706afdec893f694a9c975311e2889f6cc81 (patch)
tree05c79e83a0a31bfb96a3b06904dae4410a20ea65 /libbb
parent53e4d744b1372fd6573ca42b3ad4b30ab8810712 (diff)
downloadbusybox-w32-c97b9706afdec893f694a9c975311e2889f6cc81.tar.gz
busybox-w32-c97b9706afdec893f694a9c975311e2889f6cc81.tar.bz2
busybox-w32-c97b9706afdec893f694a9c975311e2889f6cc81.zip
Make it so we don't segfault when /proc isn't mounted -- guess pid 1...
-Erik git-svn-id: svn://busybox.net/trunk/busybox@2911 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'libbb')
-rw-r--r--libbb/find_pid_by_name.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/libbb/find_pid_by_name.c b/libbb/find_pid_by_name.c
index ea1cba65b..f335e9c1f 100644
--- a/libbb/find_pid_by_name.c
+++ b/libbb/find_pid_by_name.c
@@ -137,6 +137,10 @@ extern pid_t* find_pid_by_name( char* pidName)
137 char buffer[READ_BUF_SIZE]; 137 char buffer[READ_BUF_SIZE];
138 char name[READ_BUF_SIZE]; 138 char name[READ_BUF_SIZE];
139 139
140 /* Must skip ".." since that is outside /proc */
141 if (strcmp(next->d_name, "..") == 0)
142 continue;
143
140 /* If it isn't a number, we don't want it */ 144 /* If it isn't a number, we don't want it */
141 if (!isdigit(*next->d_name)) 145 if (!isdigit(*next->d_name))
142 continue; 146 continue;
@@ -161,6 +165,11 @@ extern pid_t* find_pid_by_name( char* pidName)
161 165
162 if (pidList) 166 if (pidList)
163 pidList[i]=0; 167 pidList[i]=0;
168 else {
169 /* If we found nothing, guess PID 1 and call it good */
170 pidList=xrealloc( pidList, sizeof(pid_t));
171 pidList[0]=1;
172 }
164 return pidList; 173 return pidList;
165} 174}
166#endif /* BB_FEATURE_USE_DEVPS_PATCH */ 175#endif /* BB_FEATURE_USE_DEVPS_PATCH */