Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(538)

Unified Diff: runtime/bin/process_linux.cc

Issue 10166029: Support passing an environment variable map to child processes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/process_impl.dart ('k') | runtime/bin/process_macos.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/process_linux.cc
diff --git a/runtime/bin/process_linux.cc b/runtime/bin/process_linux.cc
index 90c36ba788b92606bef1209cfc3582f7c9760731..184173aa5c4d8740c24bba322132ebd63fe27412 100644
--- a/runtime/bin/process_linux.cc
+++ b/runtime/bin/process_linux.cc
@@ -307,6 +307,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,
@@ -390,12 +392,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;
@@ -450,13 +461,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));
« no previous file with comments | « runtime/bin/process_impl.dart ('k') | runtime/bin/process_macos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698