Skip to content

Use POSIX_SPAWN_CLOEXEC_DEFAULT in posix_spawn.c when available #254

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions cbits/posix/posix_spawn.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,15 @@ do_spawn_posix (char *const args[],
if (childGroup || childUser) {
return -2;
}

short spawn_flags = 0;

if ((flags & RUN_PROCESS_IN_CLOSE_FDS) != 0) {
// TODO: can this be efficiently supported?
#if defined(HAVE_POSIX_SPAWN_CLOEXEC_DEFAULT)
spawn_flags |= POSIX_SPAWN_CLOEXEC_DEFAULT;
#else
return -2;
#endif
}

// Now the main act...
Expand All @@ -107,7 +113,6 @@ do_spawn_posix (char *const args[],
posix_spawnattr_t sa;
int r;
ProcHandle ret;
short spawn_flags = 0;

r = posix_spawn_file_actions_init(&fa);
if (r != 0) {
Expand Down
4 changes: 4 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ AC_CHECK_DECLS([POSIX_SPAWN_SETSID, POSIX_SPAWN_SETSID_NP],[],[],[
#define _GNU_SOURCE
#include <spawn.h>
])
AC_CHECK_DECLS([POSIX_SPAWN_CLOEXEC_DEFAULT],[],[],[
#define _GNU_SOURCE
#include <spawn.h>
])
AC_CHECK_DECLS([POSIX_SPAWN_SETPGROUP],[],[],[
#define _GNU_SOURCE
#include <spawn.h>
Expand Down