From 896c28b0c8374c07d26d43c12d238d697d1d8a07 Mon Sep 17 00:00:00 2001 From: aeiouaeiouaeiouaeiouaeiouaeiou Date: Fri, 29 Aug 2025 13:43:28 +0300 Subject: [PATCH] os.c: use JANET_SPAWN_NO_CHDIR macros for macOS <10.15 Signed-off-by: aeiouaeiouaeiouaeiouaeiouaeiou --- src/core/os.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/core/os.c b/src/core/os.c index aa052a18..2e638775 100644 --- a/src/core/os.c +++ b/src/core/os.c @@ -66,6 +66,7 @@ #ifdef JANET_APPLE #include #define environ (*_NSGetEnviron()) +#include #else extern char **environ; #endif @@ -81,8 +82,14 @@ extern char **environ; #ifndef JANET_SPAWN_NO_CHDIR #ifdef __GLIBC__ #define JANET_SPAWN_CHDIR -#elif defined(JANET_APPLE) /* Some older versions may not work here. */ +#elif defined(JANET_APPLE) +/* The posix_spawn_file_actions_addchdir_np function + * has only been implemented since macOS 10.15 */ +#if defined(MAC_OS_X_VERSION_10_15) && (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15) #define JANET_SPAWN_CHDIR +#else +#define JANET_SPAWN_NO_CHDIR +#endif #elif defined(__FreeBSD__) /* Not all BSDs work, for example openBSD doesn't seem to support this */ #define JANET_SPAWN_CHDIR #endif