OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
233 typedef int* LaunchSynchronizationHandle; | 233 typedef int* LaunchSynchronizationHandle; |
234 #endif // defined(OS_MACOSX) | 234 #endif // defined(OS_MACOSX) |
235 | 235 |
236 // Options for launching a subprocess that are passed to LaunchProcess(). | 236 // Options for launching a subprocess that are passed to LaunchProcess(). |
237 // The default constructor constructs the object with default options. | 237 // The default constructor constructs the object with default options. |
238 struct LaunchOptions { | 238 struct LaunchOptions { |
239 LaunchOptions() : wait(false), | 239 LaunchOptions() : wait(false), |
240 #if defined(OS_WIN) | 240 #if defined(OS_WIN) |
241 start_hidden(false), inherit_handles(false), as_user(NULL), | 241 start_hidden(false), inherit_handles(false), as_user(NULL), |
242 empty_desktop_name(false), job_handle(NULL), | 242 empty_desktop_name(false), job_handle(NULL), |
243 stdin_handle(NULL), | |
244 stdout_handle(NULL), | |
245 stderr_handle(NULL), | |
243 force_breakaway_from_job_(false) | 246 force_breakaway_from_job_(false) |
244 #else | 247 #else |
245 environ(NULL), fds_to_remap(NULL), maximize_rlimits(NULL), | 248 environ(NULL), fds_to_remap(NULL), maximize_rlimits(NULL), |
246 new_process_group(false) | 249 new_process_group(false) |
247 #if defined(OS_LINUX) | 250 #if defined(OS_LINUX) |
248 , clone_flags(0) | 251 , clone_flags(0) |
249 #endif // OS_LINUX | 252 #endif // OS_LINUX |
250 #if defined(OS_CHROMEOS) | 253 #if defined(OS_CHROMEOS) |
251 , ctrl_terminal_fd(-1) | 254 , ctrl_terminal_fd(-1) |
252 #endif // OS_CHROMEOS | 255 #endif // OS_CHROMEOS |
253 #if defined(OS_MACOSX) | 256 #if defined(OS_MACOSX) |
254 , synchronize(NULL) | 257 , synchronize(NULL) |
255 #endif // defined(OS_MACOSX) | 258 #endif // defined(OS_MACOSX) |
256 #endif // !defined(OS_WIN) | 259 #endif // !defined(OS_WIN) |
257 {} | 260 {} |
258 | 261 |
259 // If true, wait for the process to complete. | 262 // If true, wait for the process to complete. |
260 bool wait; | 263 bool wait; |
261 | 264 |
262 #if defined(OS_WIN) | 265 #if defined(OS_WIN) |
263 bool start_hidden; | 266 bool start_hidden; |
264 | 267 |
265 // If true, the new process inherits handles from the parent. | 268 // If true, the new process inherits handles from the parent. In production |
269 // code this flag should be used only when running trusted binaries, because | |
270 // it may cause some handles to be leaked to the process being launched. | |
jschuh
2013/01/04 21:57:06
More accurately, it should be something like:
...
Sergey Ulanov
2013/01/05 00:33:05
Done.
| |
266 bool inherit_handles; | 271 bool inherit_handles; |
267 | 272 |
268 // If non-NULL, runs as if the user represented by the token had launched it. | 273 // If non-NULL, runs as if the user represented by the token had launched it. |
269 // Whether the application is visible on the interactive desktop depends on | 274 // Whether the application is visible on the interactive desktop depends on |
270 // the token belonging to an interactive logon session. | 275 // the token belonging to an interactive logon session. |
271 // | 276 // |
272 // To avoid hard to diagnose problems, when specified this loads the | 277 // To avoid hard to diagnose problems, when specified this loads the |
273 // environment variables associated with the user and if this operation fails | 278 // environment variables associated with the user and if this operation fails |
274 // the entire call fails as well. | 279 // the entire call fails as well. |
275 UserTokenHandle as_user; | 280 UserTokenHandle as_user; |
276 | 281 |
277 // If true, use an empty string for the desktop name. | 282 // If true, use an empty string for the desktop name. |
278 bool empty_desktop_name; | 283 bool empty_desktop_name; |
279 | 284 |
280 // If non-NULL, launches the application in that job object. The process will | 285 // If non-NULL, launches the application in that job object. The process will |
281 // be terminated immediately and LaunchProcess() will fail if assignment to | 286 // be terminated immediately and LaunchProcess() will fail if assignment to |
282 // the job object fails. | 287 // the job object fails. |
283 HANDLE job_handle; | 288 HANDLE job_handle; |
284 | 289 |
290 // Handles for the redirection of stdin, stdout and stderr. The handles must | |
291 // be inheritable. Caller should either set all three of them or none (i.e. | |
292 // there is no way to redirect stderr without redirecting stdin). The | |
293 // |inherit_handles| flag must be set to true when redirecting stdio stream. | |
294 HANDLE stdin_handle; | |
295 HANDLE stdout_handle; | |
296 HANDLE stderr_handle; | |
297 | |
285 // If set to true, ensures that the child process is launched with the | 298 // If set to true, ensures that the child process is launched with the |
286 // CREATE_BREAKAWAY_FROM_JOB flag which allows it to breakout of the parent | 299 // CREATE_BREAKAWAY_FROM_JOB flag which allows it to breakout of the parent |
287 // job if any. | 300 // job if any. |
288 bool force_breakaway_from_job_; | 301 bool force_breakaway_from_job_; |
289 #else | 302 #else |
290 // If non-NULL, set/unset environment variables. | 303 // If non-NULL, set/unset environment variables. |
291 // See documentation of AlterEnvironment(). | 304 // See documentation of AlterEnvironment(). |
292 // This pointer is owned by the caller and must live through the | 305 // This pointer is owned by the caller and must live through the |
293 // call to LaunchProcess(). | 306 // call to LaunchProcess(). |
294 const EnvironmentVector* environ; | 307 const EnvironmentVector* environ; |
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
883 // YOUR CODE IS LIKELY TO BE REVERTED. THANK YOU. | 896 // YOUR CODE IS LIKELY TO BE REVERTED. THANK YOU. |
884 // | 897 // |
885 // TODO(shess): Weird place to put it, but this is where the OOM | 898 // TODO(shess): Weird place to put it, but this is where the OOM |
886 // killer currently lives. | 899 // killer currently lives. |
887 BASE_EXPORT void* UncheckedMalloc(size_t size); | 900 BASE_EXPORT void* UncheckedMalloc(size_t size); |
888 #endif // defined(OS_MACOSX) | 901 #endif // defined(OS_MACOSX) |
889 | 902 |
890 } // namespace base | 903 } // namespace base |
891 | 904 |
892 #endif // BASE_PROCESS_UTIL_H_ | 905 #endif // BASE_PROCESS_UTIL_H_ |
OLD | NEW |