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 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
87 // termination status. | 87 // termination status. |
88 // | 88 // |
89 // Note that it is not an option to call WaitForExitCode and then | 89 // Note that it is not an option to call WaitForExitCode and then |
90 // GetTerminationStatus as the child will be reaped when WaitForExitCode | 90 // GetTerminationStatus as the child will be reaped when WaitForExitCode |
91 // returns, and this information will be lost. | 91 // returns, and this information will be lost. |
92 // | 92 // |
93 BASE_EXPORT TerminationStatus GetKnownDeadTerminationStatus( | 93 BASE_EXPORT TerminationStatus GetKnownDeadTerminationStatus( |
94 ProcessHandle handle, int* exit_code); | 94 ProcessHandle handle, int* exit_code); |
95 #endif // defined(OS_POSIX) | 95 #endif // defined(OS_POSIX) |
96 | 96 |
97 // Waits for process to exit. On POSIX systems, if the process hasn't been | |
98 // signaled then puts the exit code in |exit_code|; otherwise it's considered | |
99 // a failure. On Windows |exit_code| is always filled. Returns true on success, | |
100 // and closes |handle| in any case. | |
101 BASE_EXPORT bool WaitForExitCode(ProcessHandle handle, int* exit_code); | |
102 | |
103 // Waits for process to exit. If it did exit within |timeout_milliseconds|, | |
104 // then puts the exit code in |exit_code|, and returns true. | |
105 // In POSIX systems, if the process has been signaled then |exit_code| is set | |
106 // to -1. Returns false on failure (the caller is then responsible for closing | |
107 // |handle|). | |
108 // The caller is always responsible for closing the |handle|. | |
109 BASE_EXPORT bool WaitForExitCodeWithTimeout(ProcessHandle handle, | |
110 int* exit_code, | |
111 base::TimeDelta timeout); | |
112 | |
113 // Wait for all the processes based on the named executable to exit. If filter | 97 // Wait for all the processes based on the named executable to exit. If filter |
114 // is non-null, then only processes selected by the filter are waited on. | 98 // is non-null, then only processes selected by the filter are waited on. |
115 // Returns after all processes have exited or wait_milliseconds have expired. | 99 // Returns after all processes have exited or wait_milliseconds have expired. |
116 // Returns true if all the processes exited, false otherwise. | 100 // Returns true if all the processes exited, false otherwise. |
117 BASE_EXPORT bool WaitForProcessesToExit( | 101 BASE_EXPORT bool WaitForProcessesToExit( |
118 const FilePath::StringType& executable_name, | 102 const FilePath::StringType& executable_name, |
119 base::TimeDelta wait, | 103 base::TimeDelta wait, |
120 const ProcessFilter* filter); | 104 const ProcessFilter* filter); |
121 | 105 |
122 // Waits a certain amount of time (can be 0) for all the processes with a given | 106 // Waits a certain amount of time (can be 0) for all the processes with a given |
(...skipping 22 matching lines...) Expand all Loading... | |
145 // SYNCHRONIZE permissions. | 129 // SYNCHRONIZE permissions. |
146 // | 130 // |
147 BASE_EXPORT void EnsureProcessTerminated(Process process); | 131 BASE_EXPORT void EnsureProcessTerminated(Process process); |
148 | 132 |
149 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 133 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
150 // The nicer version of EnsureProcessTerminated() that is patient and will | 134 // The nicer version of EnsureProcessTerminated() that is patient and will |
151 // wait for |pid| to finish and then reap it. | 135 // wait for |pid| to finish and then reap it. |
152 BASE_EXPORT void EnsureProcessGetsReaped(ProcessId pid); | 136 BASE_EXPORT void EnsureProcessGetsReaped(ProcessId pid); |
153 #endif | 137 #endif |
154 | 138 |
139 #if defined(OS_POSIX) | |
140 namespace internal { | |
141 // Implements Process::WaitForExitWithTimeout for POSIX. It lives in this file | |
142 // because the implementation is closely related to other functions declared | |
danakj
2015/02/26 22:03:25
Why does this argument make sense for posix but no
rvargas (doing something else)
2015/02/27 01:54:18
Because the windows implementation has nothing to
danakj
2015/02/27 18:47:02
Granted the posix code is larger, with some helper
| |
143 // here. | |
144 // This is not meant for consumers outside of base::Process. | |
danakj
2015/02/26 22:03:25
Can you still keep the whole comment that was on t
rvargas (doing something else)
2015/02/27 01:54:18
Some of that text is now irrelevant (the part abou
| |
145 bool WaitForExitCodeWithTimeout(ProcessHandle handle, | |
146 int* exit_code, | |
147 TimeDelta timeout); | |
148 static const int kNoTimeout = -1; | |
danakj
2015/02/26 22:03:25
maybe you can scope this constant name a bit more.
rvargas (doing something else)
2015/02/27 01:54:18
Removed.
| |
149 } // namespace internal | |
150 #endif // defined(OS_POSIX) | |
151 | |
155 } // namespace base | 152 } // namespace base |
156 | 153 |
157 #endif // BASE_PROCESS_KILL_H_ | 154 #endif // BASE_PROCESS_KILL_H_ |
OLD | NEW |