OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/process/kill.h" | 5 #include "base/process/kill.h" |
6 | 6 |
7 #include <signal.h> | 7 #include <signal.h> |
8 #include <sys/types.h> | 8 #include <sys/types.h> |
9 #include <sys/wait.h> | 9 #include <sys/wait.h> |
10 #include <unistd.h> | 10 #include <unistd.h> |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 bool result = kill(-1 * process_group_id, SIGKILL) == 0; | 188 bool result = kill(-1 * process_group_id, SIGKILL) == 0; |
189 if (!result) | 189 if (!result) |
190 DPLOG(ERROR) << "Unable to terminate process group " << process_group_id; | 190 DPLOG(ERROR) << "Unable to terminate process group " << process_group_id; |
191 return result; | 191 return result; |
192 } | 192 } |
193 | 193 |
194 TerminationStatus GetTerminationStatus(ProcessHandle handle, int* exit_code) { | 194 TerminationStatus GetTerminationStatus(ProcessHandle handle, int* exit_code) { |
195 return GetTerminationStatusImpl(handle, false /* can_block */, exit_code); | 195 return GetTerminationStatusImpl(handle, false /* can_block */, exit_code); |
196 } | 196 } |
197 | 197 |
198 TerminationStatus WaitForTerminationStatus(ProcessHandle handle, | 198 TerminationStatus GetKnownDeadTerminationStatus(ProcessHandle handle, |
199 int* exit_code) { | 199 int* exit_code) { |
| 200 bool result = kill(handle, SIGKILL) == 0; |
| 201 |
| 202 if (!result) |
| 203 DPLOG(ERROR) << "Unable to terminate process " << handle; |
| 204 |
200 return GetTerminationStatusImpl(handle, true /* can_block */, exit_code); | 205 return GetTerminationStatusImpl(handle, true /* can_block */, exit_code); |
201 } | 206 } |
202 | 207 |
203 bool WaitForExitCode(ProcessHandle handle, int* exit_code) { | 208 bool WaitForExitCode(ProcessHandle handle, int* exit_code) { |
204 int status; | 209 int status; |
205 if (HANDLE_EINTR(waitpid(handle, &status, 0)) == -1) { | 210 if (HANDLE_EINTR(waitpid(handle, &status, 0)) == -1) { |
206 NOTREACHED(); | 211 NOTREACHED(); |
207 return false; | 212 return false; |
208 } | 213 } |
209 | 214 |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 if (IsChildDead(process)) | 488 if (IsChildDead(process)) |
484 return; | 489 return; |
485 | 490 |
486 BackgroundReaper* reaper = new BackgroundReaper(process, 0); | 491 BackgroundReaper* reaper = new BackgroundReaper(process, 0); |
487 PlatformThread::CreateNonJoinable(0, reaper); | 492 PlatformThread::CreateNonJoinable(0, reaper); |
488 } | 493 } |
489 | 494 |
490 #endif // !defined(OS_MACOSX) | 495 #endif // !defined(OS_MACOSX) |
491 | 496 |
492 } // namespace base | 497 } // namespace base |
OLD | NEW |