summaryrefslogtreecommitdiff
path: root/lib/System/Unix/Program.inc
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2010-04-18 09:16:04 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2010-04-18 09:16:04 +0000
commitbceaffc7cc1c484a1bb353e1d8ac42d2e8e57f69 (patch)
treee7d01ff4fb93be1625225ce0d8963d076bd5e3a3 /lib/System/Unix/Program.inc
parent6523803203b9cc81386a76cce413db8907796e92 (diff)
downloadllvm-bceaffc7cc1c484a1bb353e1d8ac42d2e8e57f69.tar.gz
llvm-bceaffc7cc1c484a1bb353e1d8ac42d2e8e57f69.tar.bz2
llvm-bceaffc7cc1c484a1bb353e1d8ac42d2e8e57f69.tar.xz
Properly inherit the environment on darwin where environ is not available for shared libraries.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101710 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/System/Unix/Program.inc')
-rw-r--r--lib/System/Unix/Program.inc7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/System/Unix/Program.inc b/lib/System/Unix/Program.inc
index 7fdf3872dd..b7b4e9eb46 100644
--- a/lib/System/Unix/Program.inc
+++ b/lib/System/Unix/Program.inc
@@ -34,6 +34,8 @@
#include <spawn.h>
#if !defined(__APPLE__)
extern char **environ;
+#else
+#include <crt_externs.h> // _NSGetEnviron
#endif
#endif
@@ -202,8 +204,11 @@ Program::Execute(const Path &path, const char **args, const char **envp,
}
}
+ if (!envp)
#if !defined(__APPLE__)
- if (!envp) envp = (const char**)environ;
+ envp = (const char**)environ;
+#else
+ envp = (const char**)*_NSGetEnviron(); // environ is missing in dylibs.
#endif
pid_t PID;