| 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 // This file contains routines to kill processes and get the exit code and | 5 // This file contains routines to kill processes and get the exit code and |
| 6 // termination status. | 6 // termination status. |
| 7 | 7 |
| 8 #ifndef BASE_PROCESS_KILL_H_ | 8 #ifndef BASE_PROCESS_KILL_H_ |
| 9 #define BASE_PROCESS_KILL_H_ | 9 #define BASE_PROCESS_KILL_H_ |
| 10 | 10 |
| 11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
| 12 #include "base/process/process_handle.h" | 12 #include "base/process/process_handle.h" |
| 13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
| 14 | 14 |
| 15 namespace base { | 15 namespace base { |
| 16 | 16 |
| 17 class ProcessFilter; | 17 class ProcessFilter; |
| 18 | 18 |
| 19 // Return status values from GetTerminationStatus. Don't use these as | 19 // Return status values from GetTerminationStatus. Don't use these as |
| 20 // exit code arguments to KillProcess*(), use platform/application | 20 // exit code arguments to KillProcess*(), use platform/application |
| 21 // specific values instead. | 21 // specific values instead. |
| 22 enum TerminationStatus { | 22 enum TerminationStatus { |
| 23 TERMINATION_STATUS_NORMAL_TERMINATION, // zero exit status | 23 TERMINATION_STATUS_NORMAL_TERMINATION, // zero exit status |
| 24 TERMINATION_STATUS_ABNORMAL_TERMINATION, // non-zero exit status | 24 TERMINATION_STATUS_ABNORMAL_TERMINATION, // non-zero exit status |
| 25 TERMINATION_STATUS_PROCESS_WAS_KILLED, // e.g. SIGKILL or task manager kill | 25 TERMINATION_STATUS_PROCESS_WAS_KILLED, // e.g. SIGKILL or task manager kill |
| 26 TERMINATION_STATUS_PROCESS_CRASHED, // e.g. Segmentation fault | 26 TERMINATION_STATUS_PROCESS_CRASHED, // e.g. Segmentation fault |
| 27 TERMINATION_STATUS_STILL_RUNNING, // child hasn't exited yet | 27 TERMINATION_STATUS_STILL_RUNNING, // child hasn't exited yet |
| 28 #if defined(OS_ANDROID) |
| 29 // On Android processes are spawned from the system Zygote and we do not get |
| 30 // the termination status. We can't know if the termination was a crash or an |
| 31 // oom kill for sure, but we can use status of the strong process bindings as |
| 32 // a hint. |
| 33 TERMINATION_STATUS_OOM_PROTECTED, // child was protected from oom kill |
| 34 #endif |
| 28 TERMINATION_STATUS_MAX_ENUM | 35 TERMINATION_STATUS_MAX_ENUM |
| 29 }; | 36 }; |
| 30 | 37 |
| 31 // Attempts to kill all the processes on the current machine that were launched | 38 // Attempts to kill all the processes on the current machine that were launched |
| 32 // from the given executable name, ending them with the given exit code. If | 39 // from the given executable name, ending them with the given exit code. If |
| 33 // filter is non-null, then only processes selected by the filter are killed. | 40 // filter is non-null, then only processes selected by the filter are killed. |
| 34 // Returns true if all processes were able to be killed off, false if at least | 41 // Returns true if all processes were able to be killed off, false if at least |
| 35 // one couldn't be killed. | 42 // one couldn't be killed. |
| 36 BASE_EXPORT bool KillProcesses(const FilePath::StringType& executable_name, | 43 BASE_EXPORT bool KillProcesses(const FilePath::StringType& executable_name, |
| 37 int exit_code, | 44 int exit_code, |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 | 153 |
| 147 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 154 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
| 148 // The nicer version of EnsureProcessTerminated() that is patient and will | 155 // The nicer version of EnsureProcessTerminated() that is patient and will |
| 149 // wait for |process_handle| to finish and then reap it. | 156 // wait for |process_handle| to finish and then reap it. |
| 150 BASE_EXPORT void EnsureProcessGetsReaped(ProcessHandle process_handle); | 157 BASE_EXPORT void EnsureProcessGetsReaped(ProcessHandle process_handle); |
| 151 #endif | 158 #endif |
| 152 | 159 |
| 153 } // namespace base | 160 } // namespace base |
| 154 | 161 |
| 155 #endif // BASE_PROCESS_KILL_H_ | 162 #endif // BASE_PROCESS_KILL_H_ |
| OLD | NEW |