For PR351:
Implement the new environment pointer for ExecuteAndWait
llvm-svn: 18928
diff --git a/llvm/lib/System/Unix/Program.cpp b/llvm/lib/System/Unix/Program.cpp
index ae53720..35192ce 100644
--- a/llvm/lib/System/Unix/Program.cpp
+++ b/llvm/lib/System/Unix/Program.cpp
@@ -79,7 +79,8 @@
//
int
Program::ExecuteAndWait(const Path& path,
- const std::vector<std::string>& args) {
+ const std::vector<std::string>& args,
+ const char ** envp ) {
if (!path.executable())
throw path.toString() + " is not executable";
@@ -103,11 +104,15 @@
break;
// Child process: Execute the program.
- case 0:
- execve (path.c_str(), (char** const)argv, environ);
+ case 0: {
+ char** env = environ;
+ if (envp != 0)
+ env = (char**) envp;
+ execve (path.c_str(), (char** const)argv, env);
// If the execve() failed, we should exit and let the parent pick up
// our non-zero exit status.
exit (errno);
+ }
// Parent process: Break out of the switch to do our processing.
default: