diff --git a/vendor/spawn/src/spawn_stubs.c b/vendor/spawn/src/spawn_stubs.c index 2b025075879e..1c9df62312ac 100644 --- a/vendor/spawn/src/spawn_stubs.c +++ b/vendor/spawn/src/spawn_stubs.c @@ -12,10 +12,14 @@ CAMLextern int caml_convert_signal_number(int); #if defined(__APPLE__) +# include -# if defined(__MAC_OS_X_VERSION_MAX_ALLOWED) +# if (MAC_OS_X_VERSION_MAX_ALLOWED >= 1060) && !defined(__ppc__) # define USE_POSIX_SPAWN -# define vfork fork +/* vfork(2) is deprecated on macOS >= 12, so we use fork(2) instead. */ +# if MAC_OS_X_VERSION_MAX_ALLOWED >= 120000 +# define vfork fork +# endif # endif #include @@ -90,13 +94,6 @@ CAMLprim value spawn_is_osx() #if defined(__APPLE__) || defined(__HAIKU__) -/* vfork(2) is deprecated on macOS >= 12, so we use fork(2) instead. */ -# if defined(__MAC_OS_X_VERSION_MAX_ALLOWED) -# if __MAC_OS_X_VERSION_MAX_ALLOWED >= 120000 -# define vfork fork -# endif -# endif - static int safe_pipe(int fd[2]) { int i; @@ -449,7 +446,13 @@ static void init_spawn_info(struct spawn_info *info, value v_setpgid, value v_sigprocmask) { - extern char ** environ; + +#ifdef __APPLE__ +# include +# define environ (*_NSGetEnviron()) +#else + extern char **environ; +#endif info->std_fds[0] = Int_val(v_stdin); info->std_fds[1] = Int_val(v_stdout);