Chromium Code Reviews| Index: base/process/launch_posix.cc |
| diff --git a/base/process/launch_posix.cc b/base/process/launch_posix.cc |
| index ce93d5056fd838bf332da563186c5bc704130e22..a332e3c04821644fd7b85d715c6d44d24150b1f6 100644 |
| --- a/base/process/launch_posix.cc |
| +++ b/base/process/launch_posix.cc |
| @@ -348,6 +348,10 @@ Process LaunchProcess(const std::vector<std::string>& argv, |
| fd_shuffle2.reserve(fd_shuffle_size); |
| scoped_ptr<char*[]> argv_cstr(new char*[argv.size() + 1]); |
| + for (size_t i = 0; i < argv.size(); i++) |
|
jln (very slow on Chromium)
2015/02/03 02:37:26
Wrong indent.
Nit: I also prefer {}, but your cho
rickyz (no longer on Chrome)
2015/02/03 02:44:44
Oops, fixed - I prefer {} too.
|
| + argv_cstr[i] = const_cast<char*>(argv[i].c_str()); |
| + argv_cstr[argv.size()] = NULL; |
| + |
| scoped_ptr<char*[]> new_environ; |
| char* const empty_environ = NULL; |
| char* const* old_environ = GetEnvironment(); |
| @@ -360,6 +364,11 @@ Process LaunchProcess(const std::vector<std::string>& argv, |
| sigfillset(&full_sigset); |
| const sigset_t orig_sigmask = SetSignalMask(full_sigset); |
| + const char* current_directory = nullptr; |
| + if (!options.current_directory.empty()) { |
| + current_directory = options.current_directory.value().c_str(); |
| + } |
| + |
| pid_t pid; |
| #if defined(OS_LINUX) |
| if (options.clone_flags) { |
| @@ -516,14 +525,15 @@ Process LaunchProcess(const std::vector<std::string>& argv, |
| #endif |
| #if defined(OS_POSIX) |
| + if (current_directory != nullptr) { |
| + RAW_CHECK(chdir(current_directory) == 0); |
| + } |
| + |
| if (options.pre_exec_delegate != nullptr) { |
| options.pre_exec_delegate->RunAsyncSafe(); |
| } |
| #endif |
| - for (size_t i = 0; i < argv.size(); i++) |
| - argv_cstr[i] = const_cast<char*>(argv[i].c_str()); |
| - argv_cstr[argv.size()] = NULL; |
| execvp(argv_cstr[0], argv_cstr.get()); |
| RAW_LOG(ERROR, "LaunchProcess: failed to execvp:"); |