aboutsummaryrefslogtreecommitdiffstats
path: root/src/libenvexec
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2025-07-21 14:02:25 +0000
committerLaurent Bercot <ska@appnovation.com>2025-07-21 14:02:25 +0000
commit2d96b5f87aecf9b3aa45761ee9d29138955bd554 (patch)
treed1115136b26b3ff7271083cac882a83f17f81fba /src/libenvexec
parent139a898a9ce4a64ecc8de6d65da1824ff3e0fb37 (diff)
downloadskalibs-2d96b5f87aecf9b3aa45761ee9d29138955bd554.tar.gz
Catch possible build failure in cspawn
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src/libenvexec')
-rw-r--r--src/libenvexec/cspawn.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/libenvexec/cspawn.c b/src/libenvexec/cspawn.c
index 654ce10..a6e1cc1 100644
--- a/src/libenvexec/cspawn.c
+++ b/src/libenvexec/cspawn.c
@@ -3,6 +3,10 @@
#include <skalibs/sysdeps.h>
#ifdef SKALIBS_HASPOSIXSPAWN
+#undef SKALIBS_POSIXSPAWNEARLYRETURN_WORKAROUND
+#if defined(SKALIBS_HASPOSIXSPAWNEARLYRETURN) && defined(SKALIBS_HASWAITID)
+# define SKALIBS_POSIXSPAWNEARLYRETURN_WORKAROUND
+#endif
#include <skalibs/nonposix.h>
#endif
@@ -95,12 +99,7 @@ static inline pid_t cspawn_fork (char const *prog, char const *const *argv, char
return pid ;
}
- /*
- guess who has a buggy posix_spawn() *and* doesn't have waitid() to work around it?
- if you guessed OpenBSD, you're right!
- */
-
-#if defined(SKALIBS_HASPOSIXSPAWN) && (!defined(SKALIBS_HASPOSIXSPAWNEARLYRETURN) || defined(SKALIBS_HASWAITID))
+#if defined(SKALIBS_HASPOSIXSPAWN) && (!defined(SKALIBS_HASPOSIXSPAWNEARLYRETURN) || defined(SKALIBS_POSIXSPAWNEARLYRETURN_WORKAROUND))
#include <signal.h>
#include <stdlib.h>
@@ -109,7 +108,7 @@ static inline pid_t cspawn_fork (char const *prog, char const *const *argv, char
#include <skalibs/config.h>
#include <skalibs/djbunix.h>
-#ifdef SKALIBS_HASPOSIXSPAWNEARLYRETURN
+#ifdef SKALIBS_POSIXSPAWNEARLYRETURN_WORKAROUND
#include <sys/wait.h>
@@ -149,7 +148,7 @@ static inline pid_t cspawn_pspawn (char const *prog, char const *const *argv, ch
posix_spawn_file_actions_t actions ;
int e ;
int nopath = !getenv("PATH") ;
-#ifdef SKALIBS_HASPOSIXSPAWNEARLYRETURN
+#ifdef SKALIBS_POSIXSPAWNEARLYRETURN_WORKAROUND
int p[2] ;
if (pipecoe(p) == -1) return 0 ;
#endif
@@ -242,7 +241,7 @@ static inline pid_t cspawn_pspawn (char const *prog, char const *const *argv, ch
if (n) posix_spawn_file_actions_destroy(&actions) ;
if (flags) posix_spawnattr_destroy(&attr) ;
-#ifdef SKALIBS_HASPOSIXSPAWNEARLYRETURN
+#ifdef SKALIBS_POSIXSPAWNEARLYRETURN_WORKAROUND
return cspawn_workaround(pid, p) ;
#else
return pid ;
@@ -253,7 +252,7 @@ static inline pid_t cspawn_pspawn (char const *prog, char const *const *argv, ch
errattr:
if (flags) posix_spawnattr_destroy(&attr) ;
err:
-#ifdef SKALIBS_HASPOSIXSPAWNEARLYRETURN
+#ifdef SKALIBS_POSIXSPAWNEARLYRETURN_WORKAROUND
fd_close(p[1]) ;
fd_close(p[0]) ;
#endif