diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/include/skalibs/cspawn.h | 1 | ||||
-rw-r--r-- | src/libenvexec/cspawn.c | 17 |
2 files changed, 5 insertions, 13 deletions
diff --git a/src/include/skalibs/cspawn.h b/src/include/skalibs/cspawn.h index 0d8dd50..7f3adf7 100644 --- a/src/include/skalibs/cspawn.h +++ b/src/include/skalibs/cspawn.h @@ -9,6 +9,7 @@ #define CSPAWN_FLAGS_SELFPIPE_FINISH 0x0001U #define CSPAWN_FLAGS_SIGBLOCKNONE 0x0002U #define CSPAWN_FLAGS_SETSID 0x0004U +#define CSPAWN_FLAGS_NEWPIDNS 0x8000U enum cspawn_fileaction_type_e { diff --git a/src/libenvexec/cspawn.c b/src/libenvexec/cspawn.c index e5e0c4f..654ce10 100644 --- a/src/libenvexec/cspawn.c +++ b/src/libenvexec/cspawn.c @@ -11,6 +11,7 @@ #include <skalibs/allreadwrite.h> #include <skalibs/sig.h> +#include <skalibs/posixplz.h> #include <skalibs/djbunix.h> #include <skalibs/selfpipe.h> #include <skalibs/exec.h> @@ -62,7 +63,7 @@ static inline pid_t cspawn_fork (char const *prog, char const *const *argv, char char c ; if (pipecoe(p) == -1) return 0 ; - pid = fork() ; + pid = flags & CSPAWN_FLAGS_NEWPIDNS ? fork_newpid() : fork() ; if (pid == -1) { fd_close(p[1]) ; @@ -71,7 +72,7 @@ static inline pid_t cspawn_fork (char const *prog, char const *const *argv, char } if (!pid) { - cspawn_child_exec(prog, argv, envp, flags, fa, n) ; + cspawn_child_exec(prog, argv, envp, flags & ~CSPAWN_FLAGS_NEWPIDNS, fa, n) ; c = errno ; fd_write(p[1], &c, 1) ; _exit(127) ; @@ -260,17 +261,9 @@ static inline pid_t cspawn_pspawn (char const *prog, char const *const *argv, ch return 0 ; } -#if (defined(SKALIBS_HASPOSIXSPAWNSETSID) || defined(SKALIBS_HASPOSIXSPAWNSETSIDNP)) && (defined(SKALIBS_HASPOSIXSPAWNCHDIR) || defined(SKALIBS_HASPOSIXSPAWNCHDIRNP)) - -pid_t cspawn (char const *prog, char const *const *argv, char const *const *envp, uint16_t flags, cspawn_fileaction const *fa, size_t n) -{ - return cspawn_pspawn(prog, argv, envp, flags, fa, n) ; -} - -#else - pid_t cspawn (char const *prog, char const *const *argv, char const *const *envp, uint16_t flags, cspawn_fileaction const *fa, size_t n) { + if (flags & CSPAWN_FLAGS_NEWPIDNS) goto dofork ; #if !defined(SKALIBS_HASPOSIXSPAWNSETSID) && !defined(SKALIBS_HASPOSIXSPAWNSETSIDNP) if (flags & CSPAWN_FLAGS_SETSID) goto dofork ; #endif @@ -285,8 +278,6 @@ pid_t cspawn (char const *prog, char const *const *argv, char const *const *envp return cspawn_fork(prog, argv, envp, flags, fa, n) ; } -#endif - #else pid_t cspawn (char const *prog, char const *const *argv, char const *const *envp, uint16_t flags, cspawn_fileaction const *fa, size_t n) |