From 2b694c49bbd78a2848a94f97786706f4a665877a Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Sun, 18 Apr 2010 06:22:26 +0000 Subject: [PATCH] Fix linux build. posix_spawn doesn't inherit the environment by default. llvm-svn: 101701 --- lib/System/Unix/Program.inc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/System/Unix/Program.inc b/lib/System/Unix/Program.inc index 44e831ff2d3..476e90b38b2 100644 --- a/lib/System/Unix/Program.inc +++ b/lib/System/Unix/Program.inc @@ -34,6 +34,8 @@ #include #endif +extern char **environ; + namespace llvm { using namespace sys; @@ -126,7 +128,7 @@ static bool RedirectIO(const Path *Path, int FD, std::string* ErrMsg) { #ifdef HAVE_POSIX_SPAWN static bool RedirectIO_PS(const Path *Path, int FD, std::string *ErrMsg, - posix_spawn_file_actions_t &FileActions) { + posix_spawn_file_actions_t &FileActions) { if (Path == 0) // Noop return false; std::string File; @@ -200,6 +202,7 @@ Program::Execute(const Path &path, const char **args, const char **envp, } pid_t PID; + if (!envp) envp = (const char**)environ; int Err = posix_spawn(&PID, path.c_str(), &FileActions, /*attrp*/0, (char**)args, (char**)envp);