OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 functions for launching subprocesses. | 5 // This file contains functions for launching subprocesses. |
6 | 6 |
7 #ifndef BASE_PROCESS_LAUNCH_H_ | 7 #ifndef BASE_PROCESS_LAUNCH_H_ |
8 #define BASE_PROCESS_LAUNCH_H_ | 8 #define BASE_PROCESS_LAUNCH_H_ |
9 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 // Look up the bootstrap server named |replacement_bootstrap_name| via the | 284 // Look up the bootstrap server named |replacement_bootstrap_name| via the |
285 // current |bootstrap_port|. Then replace the task's bootstrap port with the | 285 // current |bootstrap_port|. Then replace the task's bootstrap port with the |
286 // received right. | 286 // received right. |
287 void ReplaceBootstrapPort(const std::string& replacement_bootstrap_name); | 287 void ReplaceBootstrapPort(const std::string& replacement_bootstrap_name); |
288 #endif // defined(OS_MACOSX) | 288 #endif // defined(OS_MACOSX) |
289 | 289 |
290 // Creates a LaunchOptions object suitable for launching processes in a test | 290 // Creates a LaunchOptions object suitable for launching processes in a test |
291 // binary. This should not be called in production/released code. | 291 // binary. This should not be called in production/released code. |
292 BASE_EXPORT LaunchOptions LaunchOptionsForTest(); | 292 BASE_EXPORT LaunchOptions LaunchOptionsForTest(); |
293 | 293 |
| 294 #if defined(OS_LINUX) |
| 295 // A wrapper for clone with fork-like behavior, meaning that it returns the |
| 296 // child's pid in the parent and 0 in the child. |flags|, |ptid|, and |ctid| are |
| 297 // as in the clone system call (the CLONE_VM flag is not supported). |
| 298 // |
| 299 // This function uses the libc clone wrapper (which updates libc's pid cache) |
| 300 // internally, so callers may expect things like getpid() to work correctly |
| 301 // after in both the child and parent. An exception is when this code is run |
| 302 // under Valgrind. Valgrind does not support the libc clone wrapper, so the libc |
| 303 // pid cache may be incorrect after this function is called under Valgrind. |
| 304 // |
| 305 // As with fork(), callers should be extremely careful when calling this while |
| 306 // multiple threads are running, since at the time the fork happened, the |
| 307 // threads could have been in any state (potentially holding locks, etc.). |
| 308 // Callers should most likely call execve() in the child soon after calling |
| 309 // this. |
| 310 BASE_EXPORT pid_t ForkWithFlags(unsigned long flags, pid_t* ptid, pid_t* ctid); |
| 311 #endif |
| 312 |
294 } // namespace base | 313 } // namespace base |
295 | 314 |
296 #endif // BASE_PROCESS_LAUNCH_H_ | 315 #endif // BASE_PROCESS_LAUNCH_H_ |
OLD | NEW |