mirror of
https://github.com/sheumann/hush.git
synced 2025-03-11 18:30:22 +00:00
Make it so we don't segfault when /proc isn't mounted -- guess pid 1...
-Erik
This commit is contained in:
parent
5ef5614c31
commit
91a6318d55
@ -137,6 +137,10 @@ extern pid_t* find_pid_by_name( char* pidName)
|
|||||||
char buffer[READ_BUF_SIZE];
|
char buffer[READ_BUF_SIZE];
|
||||||
char name[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 it isn't a number, we don't want it */
|
||||||
if (!isdigit(*next->d_name))
|
if (!isdigit(*next->d_name))
|
||||||
continue;
|
continue;
|
||||||
@ -161,6 +165,11 @@ extern pid_t* find_pid_by_name( char* pidName)
|
|||||||
|
|
||||||
if (pidList)
|
if (pidList)
|
||||||
pidList[i]=0;
|
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;
|
return pidList;
|
||||||
}
|
}
|
||||||
#endif /* BB_FEATURE_USE_DEVPS_PATCH */
|
#endif /* BB_FEATURE_USE_DEVPS_PATCH */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user