| Index: runtime/bin/process_macos.cc
|
| diff --git a/runtime/bin/process_macos.cc b/runtime/bin/process_macos.cc
|
| index c71aca369b5648eee86817e715ce297f536c3787..f71b461dd36a3bd240ca84d310e9223c33cf1293 100644
|
| --- a/runtime/bin/process_macos.cc
|
| +++ b/runtime/bin/process_macos.cc
|
| @@ -306,6 +306,8 @@ int Process::Start(const char* path,
|
| char* arguments[],
|
| intptr_t arguments_length,
|
| const char* working_directory,
|
| + char* environment[],
|
| + intptr_t environment_length,
|
| intptr_t* in,
|
| intptr_t* out,
|
| intptr_t* err,
|
| @@ -389,12 +391,21 @@ int Process::Start(const char* path,
|
| }
|
|
|
| char** program_arguments = new char*[arguments_length + 2];
|
| - program_arguments[0] = const_cast<char *>(path);
|
| + program_arguments[0] = const_cast<char*>(path);
|
| for (int i = 0; i < arguments_length; i++) {
|
| program_arguments[i + 1] = arguments[i];
|
| }
|
| program_arguments[arguments_length + 1] = NULL;
|
|
|
| + char** program_environment = NULL;
|
| + if (environment != NULL) {
|
| + program_environment = new char*[environment_length + 1];
|
| + for (int i = 0; i < environment_length; i++) {
|
| + program_environment[i] = environment[i];
|
| + }
|
| + program_environment[environment_length] = NULL;
|
| + }
|
| +
|
| struct sigaction act;
|
| bzero(&act, sizeof(act));
|
| act.sa_sigaction = SigChldHandler;
|
| @@ -449,13 +460,22 @@ int Process::Start(const char* path,
|
| ReportChildError(exec_control[1]);
|
| }
|
|
|
| - TEMP_FAILURE_RETRY(
|
| - execvp(path, const_cast<char* const*>(program_arguments)));
|
| + if (environment != NULL) {
|
| + TEMP_FAILURE_RETRY(
|
| + execve(path,
|
| + const_cast<char* const*>(program_arguments),
|
| + program_environment));
|
| + } else {
|
| + TEMP_FAILURE_RETRY(
|
| + execvp(path, const_cast<char* const*>(program_arguments)));
|
| + }
|
| ReportChildError(exec_control[1]);
|
| }
|
|
|
| - // The arguments for the spawned process are not needed any longer.
|
| + // The arguments and environment for the spawned process are not needed
|
| + // any longer.
|
| delete[] program_arguments;
|
| + delete[] program_environment;
|
|
|
| int event_fds[2];
|
| result = TEMP_FAILURE_RETRY(pipe(event_fds));
|
|
|