diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2023-09-11 22:57:08 +0000 |
---|---|---|
committer | Laurent Bercot <ska@appnovation.com> | 2023-09-11 22:57:08 +0000 |
commit | 32544468e5db6a2635b6c0f9e261a288fe7179e9 (patch) | |
tree | 9a201bcbd941ab808e0d3d0386aa3b4713f6dac3 /src/sysdeps | |
parent | beb9f82f12972b4f4b8830701c4d7ba02ddfbceb (diff) | |
download | skalibs-32544468e5db6a2635b6c0f9e261a288fe7179e9.tar.xz |
Add POSIX_SPAWN_SETSID_NP support
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src/sysdeps')
-rw-r--r-- | src/sysdeps/tryposixspawnsetsidnp.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/sysdeps/tryposixspawnsetsidnp.c b/src/sysdeps/tryposixspawnsetsidnp.c new file mode 100644 index 0000000..fd7659d --- /dev/null +++ b/src/sysdeps/tryposixspawnsetsidnp.c @@ -0,0 +1,30 @@ +/* ISC license. */ + +#undef _POSIX_C_SOURCE +#undef _XOPEN_SOURCE + +#ifndef _XPG4_2 +#define _XPG4_2 +#endif + +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif + +#ifndef _DEFAULT_SOURCE +#define _DEFAULT_SOURCE +#endif + +#include <spawn.h> + +int main (void) +{ + pid_t pid ; + posix_spawn_file_actions_t actions ; + posix_spawnattr_t attr ; + char *const argv[2] = { "/bin/true", 0 } ; + char *const envp[1] = { 0 } ; + posix_spawnattr_setflags(&attr, POSIX_SPAWN_SETSID_NP) ; + posix_spawn_file_actions_init(&actions) ; + return posix_spawn(&pid, argv[0], 0, 0, argv, envp) ; +} |