Skip to content

Commit 6bb384d

Browse files
committed
Use _NSGetEnviron on OSX. Fixes #3446.
1 parent f264f92 commit 6bb384d

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

vm/ffi_util.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,23 @@
1919
#include "windows_compat.h"
2020
#include "ffi_util.hpp"
2121

22+
#ifdef __APPLE__
23+
#include <crt_externs.h>
24+
#endif
25+
2226
extern "C" {
2327

2428
extern char** environ;
2529

2630
int ffi_errno() { return errno; }
2731

28-
char** ffi_environ() { return environ; }
32+
char** ffi_environ() {
33+
#ifdef __APPLE__
34+
return *_NSGetEnviron();
35+
#else
36+
return environ;
37+
#endif
38+
}
2939

3040
void ffi_set_errno(int n) {
3141
errno = n;

0 commit comments

Comments
 (0)