| Index: base/process/launch_posix.cc
|
| diff --git a/base/process/launch_posix.cc b/base/process/launch_posix.cc
|
| index ce93d5056fd838bf332da563186c5bc704130e22..203b7c8b9a71830f3a21e72e6700695dbdc76aef 100644
|
| --- a/base/process/launch_posix.cc
|
| +++ b/base/process/launch_posix.cc
|
| @@ -347,7 +347,12 @@ Process LaunchProcess(const std::vector<std::string>& argv,
|
| fd_shuffle1.reserve(fd_shuffle_size);
|
| fd_shuffle2.reserve(fd_shuffle_size);
|
|
|
| - scoped_ptr<char*[]> argv_cstr(new char*[argv.size() + 1]);
|
| + scoped_ptr<char* []> argv_cstr(new char* [argv.size() + 1]);
|
| + for (size_t i = 0; i < argv.size(); i++) {
|
| + 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 +365,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) {
|
| @@ -515,15 +525,14 @@ 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:");
|
|
|