aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2001-07-05 15:56:36 +0000
committerEric Andersen <andersen@codepoet.org>2001-07-05 15:56:36 +0000
commitd50a61956c032c9b80bee7dc58a931318d8f38da (patch)
treec53921b9a8af74a07636c74a82324d75e4255b48 /libbb
parent94f3a570e19554cddcda0e7dfa799fe8f03b4519 (diff)
downloadbusybox-d50a61956c032c9b80bee7dc58a931318d8f38da.tar.gz
Implement suggestion from Adam Slattery, (don't default to killing closing bug #1190.
Diffstat (limited to 'libbb')
-rw-r--r--libbb/find_pid_by_name.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/libbb/find_pid_by_name.c b/libbb/find_pid_by_name.c
index f335e9c1f..57decc69c 100644
--- a/libbb/find_pid_by_name.c
+++ b/libbb/find_pid_by_name.c
@@ -97,8 +97,17 @@ extern pid_t* find_pid_by_name( char* pidName)
pidList[j++]=info.pid;
}
}
- if (pidList)
+ if (pidList) {
pidList[j]=0;
+ } else if ( strcmp(pidName, "init")==0) {
+ /* If we found nothing and they were trying to kill "init",
+ * guess PID 1 and call it good... Perhaps we should simply
+ * exit if /proc isn't mounted, but this will do for now. */
+ pidList=xrealloc( pidList, sizeof(pid_t));
+ pidList[0]=1;
+ } else {
+ pidList[0]=-1;
+ }
/* Free memory */
free( pid_array);
@@ -165,10 +174,14 @@ 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 */
+ else if ( strcmp(pidName, "init")==0) {
+ /* If we found nothing and they were trying to kill "init",
+ * guess PID 1 and call it good... Perhaps we should simply
+ * exit if /proc isn't mounted, but this will do for now. */
pidList=xrealloc( pidList, sizeof(pid_t));
pidList[0]=1;
+ } else {
+ pidList[0]=-1;
}
return pidList;
}