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..0595b754c13bdb94260da3f4511f800b5d126dae 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) { |
| @@ -516,14 +526,15 @@ Process LaunchProcess(const std::vector<std::string>& argv, |
| #endif |
| #if defined(OS_POSIX) |
|
rvargas (doing something else)
2015/02/03 03:32:10
isn't this redundant?
|
| + 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:"); |