]> www.infradead.org Git - users/dwmw2/openconnect.git/commitdiff
Attempt to make posix_spawn() work on OSX
authorDavid Woodhouse <dwmw2@infradead.org>
Mon, 18 Apr 2022 14:38:57 +0000 (15:38 +0100)
committerDavid Woodhouse <dwmw2@infradead.org>
Mon, 18 Apr 2022 14:38:57 +0000 (15:38 +0100)
Fixes: #409
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
hpke.c
main.c
openconnect-internal.h

diff --git a/hpke.c b/hpke.c
index 663cab9169617ddbdca0aafad0c07f7b39b402f2..005d83b4450e6f1988b079396d0da70cd1066e21 100644 (file)
--- a/hpke.c
+++ b/hpke.c
@@ -24,10 +24,6 @@ int handle_external_browser(struct openconnect_info *vpninfo)
 }
 #else
 
-#ifdef HAVE_POSIX_SPAWN
-#include <spawn.h>
-#endif
-
 #include <ctype.h>
 
 #define HPKE_TAG_PUBKEY                1
diff --git a/main.c b/main.c
index b31e34ded7604d65547b52424ac34cbbee1c631c..81c396464889b32d9658f17f12b109c1bfd35dec 100644 (file)
--- a/main.c
+++ b/main.c
@@ -896,8 +896,8 @@ static BOOL WINAPI console_ctrl_handler(DWORD dwCtrlType)
        return TRUE;
 }
 #endif
+
 #ifdef HAVE_POSIX_SPAWN
-#include <spawn.h>
 static int spawn_browser(struct openconnect_info *vpninfo, const char *url, void *cbdata)
 {
        vpn_progress(vpninfo, PRG_TRACE,
index ee0070273ba9d7c4d2a14ec4b5c04ad359a18ac7..fb2ed2dd790b8b001fe860ff5ea83ed67d683116 100644 (file)
 #include <string.h>
 #include <errno.h>
 
+#ifdef HAVE_POSIX_SPAWN
+#ifdef __APPLE__
+#include <crt_externs.h>
+#define environ (*_NSGetEnviron())
+#endif
+#include <spawn.h>
+#endif
+
 /* Equivalent of "/dev/null" on Windows.
  * See https://stackoverflow.com/a/44163934
  */