diff options
author | Eric Andersen <andersen@codepoet.org> | 2001-07-05 15:56:36 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2001-07-05 15:56:36 +0000 |
commit | d50a61956c032c9b80bee7dc58a931318d8f38da (patch) | |
tree | c53921b9a8af74a07636c74a82324d75e4255b48 /libbb/find_pid_by_name.c | |
parent | 94f3a570e19554cddcda0e7dfa799fe8f03b4519 (diff) | |
download | busybox-w32-d50a61956c032c9b80bee7dc58a931318d8f38da.tar.gz busybox-w32-d50a61956c032c9b80bee7dc58a931318d8f38da.tar.bz2 busybox-w32-d50a61956c032c9b80bee7dc58a931318d8f38da.zip |
Implement suggestion from Adam Slattery, (don't default to killing closing bug #1190.
Diffstat (limited to 'libbb/find_pid_by_name.c')
-rw-r--r-- | libbb/find_pid_by_name.c | 19 |
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) | |||
97 | pidList[j++]=info.pid; | 97 | pidList[j++]=info.pid; |
98 | } | 98 | } |
99 | } | 99 | } |
100 | if (pidList) | 100 | if (pidList) { |
101 | pidList[j]=0; | 101 | pidList[j]=0; |
102 | } else if ( strcmp(pidName, "init")==0) { | ||
103 | /* If we found nothing and they were trying to kill "init", | ||
104 | * guess PID 1 and call it good... Perhaps we should simply | ||
105 | * exit if /proc isn't mounted, but this will do for now. */ | ||
106 | pidList=xrealloc( pidList, sizeof(pid_t)); | ||
107 | pidList[0]=1; | ||
108 | } else { | ||
109 | pidList[0]=-1; | ||
110 | } | ||
102 | 111 | ||
103 | /* Free memory */ | 112 | /* Free memory */ |
104 | free( pid_array); | 113 | free( pid_array); |
@@ -165,10 +174,14 @@ extern pid_t* find_pid_by_name( char* pidName) | |||
165 | 174 | ||
166 | if (pidList) | 175 | if (pidList) |
167 | pidList[i]=0; | 176 | pidList[i]=0; |
168 | else { | 177 | else if ( strcmp(pidName, "init")==0) { |
169 | /* If we found nothing, guess PID 1 and call it good */ | 178 | /* If we found nothing and they were trying to kill "init", |
179 | * guess PID 1 and call it good... Perhaps we should simply | ||
180 | * exit if /proc isn't mounted, but this will do for now. */ | ||
170 | pidList=xrealloc( pidList, sizeof(pid_t)); | 181 | pidList=xrealloc( pidList, sizeof(pid_t)); |
171 | pidList[0]=1; | 182 | pidList[0]=1; |
183 | } else { | ||
184 | pidList[0]=-1; | ||
172 | } | 185 | } |
173 | return pidList; | 186 | return pidList; |
174 | } | 187 | } |