Don't pull in environ, not always safe. Global variables are bad anyway.
[oota-llvm.git] / lib / System / Unix / Program.inc
index 01eefe0d52eb641ec957b7ffb6b9408a3aec89af..86a54316179ce8411c56f33a310b56a842c7ab63 100644 (file)
@@ -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);