Skip to content

Commit

Permalink
Merge pull request #304 from bgamari/wip/posix_spawn_addchrdir
Browse files Browse the repository at this point in the history
posix_spawn: Add support for posix_spawn_file_actions_addchdir_np
  • Loading branch information
bgamari authored Feb 13, 2024
2 parents dfdae0a + e4b4638 commit 53c6905
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 9 additions & 3 deletions cbits/posix/posix_spawn.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,20 @@ do_spawn_posix (char *const args[],
}

if (workingDirectory) {
#if defined(HAVE_posix_spawn_file_actions_addchdir_np)
// N.B. this function is broken on macOS.
// See https://github.com/rust-lang/rust/pull/80537.
#if defined(HAVE_posix_spawn_file_actions_addchdir)
r = posix_spawn_file_actions_addchdir(&fa, workingDirectory);
if (r != 0) {
*failed_doing = "posix_spawn_file_actions_addchdir";
goto fail;
}
#elif defined(HAVE_posix_spawn_file_actions_addchdir_np)
// N.B. this function is broken on macOS.
// See https://github.com/rust-lang/rust/pull/80537.
r = posix_spawn_file_actions_addchdir_np(&fa, workingDirectory);
if (r != 0) {
*failed_doing = "posix_spawn_file_actions_addchdir_np";
goto fail;
}
#else
goto not_supported;
#endif
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ AC_CHECK_FUNCS([pipe2],[],[],[

# posix_spawn checks
AC_CHECK_HEADERS([spawn.h])
AC_CHECK_FUNCS([posix_spawnp posix_spawn_file_actions_addchdir],[],[],[
AC_CHECK_FUNCS([posix_spawnp posix_spawn_file_actions_addchdir_np posix_spawn_file_actions_addchdir],[],[],[
#define _GNU_SOURCE
#include <spawn.h>
])
Expand Down

0 comments on commit 53c6905

Please sign in to comment.