aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 */