diff options
author | Evan Cheng <evan.cheng@apple.com> | 2006-06-09 20:43:11 +0000 |
---|---|---|
committer | Evan Cheng <evan.cheng@apple.com> | 2006-06-09 20:43:11 +0000 |
commit | 2fafaf1b01bbcb8a5db2f6ded07fb840115ca5d9 (patch) | |
tree | 9edc655274a00d4c2b5e1e3bc9becff9e795f536 /lib | |
parent | fcaf345c88bc19d0ef96bfa1eaa411cb725250ed (diff) | |
download | external_llvm-2fafaf1b01bbcb8a5db2f6ded07fb840115ca5d9.zip external_llvm-2fafaf1b01bbcb8a5db2f6ded07fb840115ca5d9.tar.gz external_llvm-2fafaf1b01bbcb8a5db2f6ded07fb840115ca5d9.tar.bz2 |
Don't pull in environ, not always safe. Global variables are bad anyway.
Use execve when explicit environment variables ptr is available. Otherwise
just use execv.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28740 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/System/Unix/Program.inc | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/lib/System/Unix/Program.inc b/lib/System/Unix/Program.inc index 01eefe0..86a5431 100644 --- a/lib/System/Unix/Program.inc +++ b/lib/System/Unix/Program.inc @@ -29,8 +29,6 @@ #include <fcntl.h> #endif -extern char** environ; - namespace llvm { using namespace sys; @@ -147,13 +145,11 @@ Program::ExecuteAndWait(const Path& path, } } - // Set up the environment - char** env = environ; - if (envp != 0) - env = (char**) envp; - // Execute! - execve (path.c_str(), (char** const)args, env); + if (envp != 0) + execve (path.c_str(), (char** const)args, (char**)envp); + else + execv (path.c_str(), (char** const)args); // If the execve() failed, we should exit and let the parent pick up // our non-zero exit status. exit (errno); |