Skip to content

Commit 7c15e7f

Browse files
authored
Merge pull request #1633 from aeiouaeiouaeiouaeiouaeiouaeiou/janet-legacy-macos1
os.c: use JANET_SPAWN_NO_CHDIR macros for macOS <10.15
2 parents 4e02f27 + 896c28b commit 7c15e7f

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/core/os.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
#ifdef JANET_APPLE
6767
#include <crt_externs.h>
6868
#define environ (*_NSGetEnviron())
69+
#include <AvailabilityMacros.h>
6970
#else
7071
extern char **environ;
7172
#endif
@@ -81,8 +82,14 @@ extern char **environ;
8182
#ifndef JANET_SPAWN_NO_CHDIR
8283
#ifdef __GLIBC__
8384
#define JANET_SPAWN_CHDIR
84-
#elif defined(JANET_APPLE) /* Some older versions may not work here. */
85+
#elif defined(JANET_APPLE)
86+
/* The posix_spawn_file_actions_addchdir_np function
87+
* has only been implemented since macOS 10.15 */
88+
#if defined(MAC_OS_X_VERSION_10_15) && (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15)
8589
#define JANET_SPAWN_CHDIR
90+
#else
91+
#define JANET_SPAWN_NO_CHDIR
92+
#endif
8693
#elif defined(__FreeBSD__) /* Not all BSDs work, for example openBSD doesn't seem to support this */
8794
#define JANET_SPAWN_CHDIR
8895
#endif

0 commit comments

Comments
 (0)