Chromium Code Reviews| Index: base/process_util_posix.cc |
| diff --git a/base/process_util_posix.cc b/base/process_util_posix.cc |
| index 1ea90c3dd4fb844cfa9e37a6a387a0a3400a815a..5233489e946328aa6e6c39b520531200c4a9dd27 100644 |
| --- a/base/process_util_posix.cc |
| +++ b/base/process_util_posix.cc |
| @@ -496,7 +496,9 @@ bool LaunchAppImpl( |
| const file_handle_mapping_vector& fds_to_remap, |
| bool wait, |
| ProcessHandle* process_handle, |
| - bool start_new_process_group) { |
| + bool start_new_process_group, |
| + bool use_clone, |
| + int clone_flags) { |
| pid_t pid; |
| InjectiveMultimap fd_shuffle1, fd_shuffle2; |
| fd_shuffle1.reserve(fds_to_remap.size()); |
| @@ -504,7 +506,11 @@ bool LaunchAppImpl( |
| scoped_array<char*> argv_cstr(new char*[argv.size() + 1]); |
| scoped_array<char*> new_environ(AlterEnvironment(env_changes, environ)); |
| - pid = fork(); |
| + if (use_clone) { |
|
agl
2011/06/10 17:28:03
#if defined(OS_LINUX)
... your code ...
#else
Brad Chen
2011/06/14 00:16:01
Done.
|
| + pid = fork(); |
| + } else { |
| + pid = syscall(__NR_clone, clone_flags, 0, 0, 0); |
| + } |
| if (pid < 0) { |
| PLOG(ERROR) << "fork"; |
| return false; |
| @@ -605,7 +611,7 @@ bool LaunchApp( |
| bool wait, |
| ProcessHandle* process_handle) { |
| return LaunchAppImpl(argv, env_changes, fds_to_remap, |
| - wait, process_handle, false); |
| + wait, process_handle, false, false, 0); |
|
agl
2011/06/10 17:28:03
optional, personal nit. I like to comment magic va
Brad Chen
2011/06/14 00:16:01
Done.
|
| } |
| bool LaunchAppInNewProcessGroup( |
| @@ -615,7 +621,16 @@ bool LaunchAppInNewProcessGroup( |
| bool wait, |
| ProcessHandle* process_handle) { |
| return LaunchAppImpl(argv, env_changes, fds_to_remap, wait, |
| - process_handle, true); |
| + process_handle, true, false, 0); |
| +} |
| + |
| +BASE_API bool LaunchAppWithClone(const std::vector<std::string>& argv, |
| + const file_handle_mapping_vector& fds_to_remap, |
| + bool wait, ProcessHandle* process_handle, |
| + int clone_flags) { |
| + base::environment_vector no_env; |
| + return LaunchAppImpl(argv, no_env, fds_to_remap, wait, process_handle, |
| + false, true, clone_flags); |
| } |
| bool LaunchApp(const std::vector<std::string>& argv, |