Skip to content

Commit

Permalink
spawn_stubs: fix for Apple
Browse files Browse the repository at this point in the history
  • Loading branch information
barracuda156 committed Oct 15, 2023
1 parent 443face commit 39703e0
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions vendor/spawn/src/spawn_stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@
CAMLextern int caml_convert_signal_number(int);

#if defined(__APPLE__)
# include <AvailabilityMacros.h>

# 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

This comment has been minimized.

Copy link
@rgrinberg

rgrinberg Oct 15, 2023

Member

I think we should have #define vfork fork on macos unconditionally. As I mentioned earlier, it just doesn't work for our use case.

# define vfork fork
# endif
# endif

#include <fcntl.h>
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 <crt_externs.h>
# define environ (*_NSGetEnviron())
#else
extern char **environ;
#endif

info->std_fds[0] = Int_val(v_stdin);
info->std_fds[1] = Int_val(v_stdout);
Expand Down

0 comments on commit 39703e0

Please sign in to comment.