OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/namespace contains utility functions for enumerating, ending and | 5 // This file/namespace contains utility functions for enumerating, ending and |
6 // computing statistics of processes. | 6 // computing statistics of processes. |
7 | 7 |
8 #ifndef BASE_PROCESS_UTIL_H_ | 8 #ifndef BASE_PROCESS_UTIL_H_ |
9 #define BASE_PROCESS_UTIL_H_ | 9 #define BASE_PROCESS_UTIL_H_ |
10 | 10 |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 bool LaunchApp(const CommandLine& cl, | 162 bool LaunchApp(const CommandLine& cl, |
163 bool wait, bool start_hidden, ProcessHandle* process_handle); | 163 bool wait, bool start_hidden, ProcessHandle* process_handle); |
164 | 164 |
165 // Executes the application specified by |cl| and wait for it to exit. Stores | 165 // Executes the application specified by |cl| and wait for it to exit. Stores |
166 // the output (stdout) in |output|. Redirects stderr to /dev/null. Returns true | 166 // the output (stdout) in |output|. Redirects stderr to /dev/null. Returns true |
167 // on success (application launched and exited cleanly, with exit code | 167 // on success (application launched and exited cleanly, with exit code |
168 // indicating success). |output| is modified only when the function finished | 168 // indicating success). |output| is modified only when the function finished |
169 // successfully. | 169 // successfully. |
170 bool GetAppOutput(const CommandLine& cl, std::string* output); | 170 bool GetAppOutput(const CommandLine& cl, std::string* output); |
171 | 171 |
| 172 #if defined(OS_POSIX) |
| 173 // A restricted version of |GetAppOutput()| which (a) clears the environment, |
| 174 // and (b) stores at most |max_output| bytes; also, it doesn't search the path |
| 175 // for the command. |
| 176 bool GetAppOutputRestricted(const CommandLine& cl, |
| 177 std::string* output, size_t max_output); |
| 178 #endif |
| 179 |
172 // Used to filter processes by process ID. | 180 // Used to filter processes by process ID. |
173 class ProcessFilter { | 181 class ProcessFilter { |
174 public: | 182 public: |
175 // Returns true to indicate set-inclusion and false otherwise. This method | 183 // Returns true to indicate set-inclusion and false otherwise. This method |
176 // should not have side-effects and should be idempotent. | 184 // should not have side-effects and should be idempotent. |
177 virtual bool Includes(ProcessId pid, ProcessId parent_pid) const = 0; | 185 virtual bool Includes(ProcessId pid, ProcessId parent_pid) const = 0; |
178 virtual ~ProcessFilter() { } | 186 virtual ~ProcessFilter() { } |
179 }; | 187 }; |
180 | 188 |
181 // Returns the number of processes on the machine that are running from the | 189 // Returns the number of processes on the machine that are running from the |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
442 // instance running inside the parent. The parent's Breakpad instance should | 450 // instance running inside the parent. The parent's Breakpad instance should |
443 // not handle the child's exceptions. Calling RestoreDefaultExceptionHandler | 451 // not handle the child's exceptions. Calling RestoreDefaultExceptionHandler |
444 // in the child after forking will restore the standard exception handler. | 452 // in the child after forking will restore the standard exception handler. |
445 // See http://crbug.com/20371/ for more details. | 453 // See http://crbug.com/20371/ for more details. |
446 void RestoreDefaultExceptionHandler(); | 454 void RestoreDefaultExceptionHandler(); |
447 #endif | 455 #endif |
448 | 456 |
449 } // namespace base | 457 } // namespace base |
450 | 458 |
451 #endif // BASE_PROCESS_UTIL_H_ | 459 #endif // BASE_PROCESS_UTIL_H_ |
OLD | NEW |