diff options
| author | andersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2001-07-05 15:56:36 +0000 |
|---|---|---|
| committer | andersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2001-07-05 15:56:36 +0000 |
| commit | 42b9b7008e4d14cfd38005f2923cfa33d8dca0de (patch) | |
| tree | c53921b9a8af74a07636c74a82324d75e4255b48 /libbb | |
| parent | 189f55f34fe457750952d5d1c37d2bb53f5325d3 (diff) | |
| download | busybox-w32-42b9b7008e4d14cfd38005f2923cfa33d8dca0de.tar.gz busybox-w32-42b9b7008e4d14cfd38005f2923cfa33d8dca0de.tar.bz2 busybox-w32-42b9b7008e4d14cfd38005f2923cfa33d8dca0de.zip | |
Implement suggestion from Adam Slattery, (don't default to killing closing bug #1190.
git-svn-id: svn://busybox.net/trunk/busybox@3003 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'libbb')
| -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 | } |
