summaryrefslogtreecommitdiffstats
path: root/llvm/lib/System/Unix/Program.cpp
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2004-12-14 04:18:51 +0000
committerReid Spencer <rspencer@reidspencer.com>2004-12-14 04:18:51 +0000
commitcdefe0aebc65dd4e5efbbbe74719c1bc886a7d31 (patch)
tree9c08b837099477b1628c1bd9c2d504122debd183 /llvm/lib/System/Unix/Program.cpp
parentc2e22fea42273eec68ce73d06a9e10fb38f79731 (diff)
downloadbcm5719-llvm-cdefe0aebc65dd4e5efbbbe74719c1bc886a7d31.tar.gz
bcm5719-llvm-cdefe0aebc65dd4e5efbbbe74719c1bc886a7d31.zip
For PR351:
Implement the new environment pointer for ExecuteAndWait llvm-svn: 18928
Diffstat (limited to 'llvm/lib/System/Unix/Program.cpp')
-rw-r--r--llvm/lib/System/Unix/Program.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/llvm/lib/System/Unix/Program.cpp b/llvm/lib/System/Unix/Program.cpp
index ae53720d1d8..35192ce7be2 100644
--- a/llvm/lib/System/Unix/Program.cpp
+++ b/llvm/lib/System/Unix/Program.cpp
@@ -79,7 +79,8 @@ Program::FindProgramByName(const std::string& progName) {
//
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 @@ Program::ExecuteAndWait(const Path& path,
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:
OpenPOWER on IntegriCloud