diff options
author | Eric Andersen <andersen@codepoet.org> | 2001-06-27 02:44:09 +0400 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2001-06-27 02:44:09 +0400 |
commit | 91a6318d555eb96f48fb8c134d5499d2f61670a0 (patch) | |
tree | 05c79e83a0a31bfb96a3b06904dae4410a20ea65 /libbb/find_pid_by_name.c | |
parent | 5ef5614c31d26a87d9d92e97bed7df7993296682 (diff) |
Make it so we don't segfault when /proc isn't mounted -- guess pid 1...
-Erik
Diffstat (limited to 'libbb/find_pid_by_name.c')
-rw-r--r-- | libbb/find_pid_by_name.c | 9 |
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) 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 */ |