diff options
author | Reid Spencer <rspencer@reidspencer.com> | 2004-12-14 04:18:51 +0000 |
---|---|---|
committer | Reid Spencer <rspencer@reidspencer.com> | 2004-12-14 04:18:51 +0000 |
commit | e2e2411f40af9611c3a0c00e21acbf86946b1fd4 (patch) | |
tree | fec42b5b97970de409400b019ee07df8a6b92ac1 /lib/System/Unix/Program.cpp | |
parent | 44f6966ef076b223b69da893c438236ea0fc677e (diff) |
For PR351:
Implement the new environment pointer for ExecuteAndWait
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@18928 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/System/Unix/Program.cpp')
-rw-r--r-- | lib/System/Unix/Program.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/System/Unix/Program.cpp b/lib/System/Unix/Program.cpp index ae53720d1d..35192ce7be 100644 --- a/lib/System/Unix/Program.cpp +++ b/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: |