Skip to content

Commit 7ab0c06

Browse files
committedMay 22, 2020
MacOS: Fix environ not being found
1 parent 1357ea1 commit 7ab0c06

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed
 

‎src/porting.cpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
4949
#if defined(__ANDROID__)
5050
#include "porting_android.h"
5151
#endif
52+
#if defined(__APPLE__)
53+
// For _NSGetEnviron()
54+
// Related: https://gitlab.haskell.org/ghc/ghc/issues/2458
55+
#include <crt_externs.h>
56+
#endif
5257

5358
#include "config.h"
5459
#include "debug.h"
@@ -718,7 +723,8 @@ bool openURL(const std::string &url)
718723
return true;
719724
#elif defined(__APPLE__)
720725
const char *argv[] = {"open", url.c_str(), NULL};
721-
return posix_spawnp(NULL, "open", NULL, NULL, (char**)argv, environ) == 0;
726+
return posix_spawnp(NULL, "open", NULL, NULL, (char**)argv,
727+
(*_NSGetEnviron())) == 0;
722728
#else
723729
const char *argv[] = {"xdg-open", url.c_str(), NULL};
724730
return posix_spawnp(NULL, "xdg-open", NULL, NULL, (char**)argv, environ) == 0;

0 commit comments

Comments
 (0)
Please sign in to comment.