diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2023-09-11 17:26:18 +0000 |
---|---|---|
committer | Laurent Bercot <ska@appnovation.com> | 2023-09-11 17:26:18 +0000 |
commit | e396f10de8804d1603a907069557b80e042f56ca (patch) | |
tree | 7b76f3a9a85d610d23bc597fa268f1a0886ea28b /src/libstddjb | |
parent | fee495136e7ee09755ee384ad0f818571859ffe1 (diff) | |
download | skalibs-e396f10de8804d1603a907069557b80e042f56ca.tar.xz |
Fix cspawn when lack of flags or actions
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src/libstddjb')
-rw-r--r-- | src/libstddjb/cspawn.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/libstddjb/cspawn.c b/src/libstddjb/cspawn.c index a4c0497..461ccd6 100644 --- a/src/libstddjb/cspawn.c +++ b/src/libstddjb/cspawn.c @@ -145,17 +145,22 @@ static inline pid_t cspawn_pspawn (char const *prog, char const *const *argv, ch if (flags) { + short pfff = 0 ; e = posix_spawnattr_init(&attr) ; if (e) goto err ; - if (flags & 3) + if (flags & (CSPAWN_FLAGS_SIGBLOCKNONE | CSPAWN_FLAGS_SELFPIPE_FINISH)) { sigset_t set ; sigemptyset(&set) ; e = posix_spawnattr_setsigmask(&attr, &set) ; if (e) goto errattr ; - e = posix_spawnattr_setflags(&attr, POSIX_SPAWN_SETSIGMASK) ; - if (e) goto errattr ; + pfff |= POSIX_SPAWN_SETSIGMASK ; } +#ifdef SKALIBS_HASPOSIXSPAWNSETSID + if (flags & CSPAWN_FLAGS_SETSID) pfff |= POSIX_SPAWN_SETSID ; +#endif + e = posix_spawnattr_setflags(&attr, pfff) ; + if (e) goto errattr ; } if (n) @@ -195,7 +200,7 @@ static inline pid_t cspawn_pspawn (char const *prog, char const *const *argv, ch } if (nopath && (setenv("PATH", SKALIBS_DEFAULTPATH, 0) == -1)) { e = errno ; goto erractions ; } - e = posix_spawnp(&pid, prog, &actions, &attr, (char *const *)argv, (char *const *)envp) ; + e = posix_spawnp(&pid, prog, n ? &actions : 0, flags ? &attr : 0, (char *const *)argv, (char *const *)envp) ; if (nopath) unsetenv("PATH") ; if (e) goto errattr ; |