projects
/
oweals
/
busybox.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
5ef5614
)
Make it so we don't segfault when /proc isn't mounted -- guess pid 1...
author
Eric Andersen
<andersen@codepoet.org>
Tue, 26 Jun 2001 22:44:09 +0000
(22:44 -0000)
committer
Eric Andersen
<andersen@codepoet.org>
Tue, 26 Jun 2001 22:44:09 +0000
(22:44 -0000)
-Erik
libbb/find_pid_by_name.c
patch
|
blob
|
history
diff --git
a/libbb/find_pid_by_name.c
b/libbb/find_pid_by_name.c
index ea1cba65b7d128cf13158159077c8ccfeaf30bf0..f335e9c1f36cfc55d101ac874395bc8c88895ecd 100644
(file)
--- 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)
char buffer[READ_BUF_SIZE];
char name[READ_BUF_SIZE];
+ /* Must skip ".." since that is outside /proc */
+ if (strcmp(next->d_name, "..") == 0)
+ continue;
+
/* If it isn't a number, we don't want it */
if (!isdigit(*next->d_name))
continue;
@@
-161,6
+165,11
@@
extern pid_t* find_pid_by_name( char* pidName)
if (pidList)
pidList[i]=0;
+ else {
+ /* If we found nothing, guess PID 1 and call it good */
+ pidList=xrealloc( pidList, sizeof(pid_t));
+ pidList[0]=1;
+ }
return pidList;
}
#endif /* BB_FEATURE_USE_DEVPS_PATCH */