summaryrefslogtreecommitdiffstats
path: root/llvm/lib/System/Unix
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2006-06-09 20:43:11 +0000
committerEvan Cheng <evan.cheng@apple.com>2006-06-09 20:43:11 +0000
commit09cf82992bae128cd4fce5093b40d6a56716e941 (patch)
treefb38199ad78c0c28fb54d571cc1d7c92a8578699 /llvm/lib/System/Unix
parentb1dc1d44f86d27562436c20a6168e46d2c87fa52 (diff)
downloadbcm5719-llvm-09cf82992bae128cd4fce5093b40d6a56716e941.tar.gz
bcm5719-llvm-09cf82992bae128cd4fce5093b40d6a56716e941.zip
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. llvm-svn: 28740
Diffstat (limited to 'llvm/lib/System/Unix')
-rw-r--r--llvm/lib/System/Unix/Program.inc12
1 files changed, 4 insertions, 8 deletions
diff --git a/llvm/lib/System/Unix/Program.inc b/llvm/lib/System/Unix/Program.inc
index 01eefe0d52e..86a54316179 100644
--- a/llvm/lib/System/Unix/Program.inc
+++ b/llvm/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);
OpenPOWER on IntegriCloud