commit 78ba749bcb8e63cbe69b59831436d28562d27b88
parent 32544468e5db6a2635b6c0f9e261a288fe7179e9
Author: Laurent Bercot <ska-skaware@skarnet.org>
Date: Tue, 12 Sep 2023 12:11:06 +0000
Add waitid() sysdep, and fuck OpenBSD
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat:
3 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/configure b/configure
@@ -630,6 +630,7 @@ choose cl splice 'splice()'
choose cl strcasestr 'strcasestr()'
choose c strnlen 'strnlen()'
choose c uint64t 'uint64_t'
+choose cl waitid 'waitid()'
choose cl futimens 'futimens()'
choose cl futimes 'futimes()'
choose cl arc4random 'arc4random()'
diff --git a/src/libstddjb/cspawn.c b/src/libstddjb/cspawn.c
@@ -96,7 +96,12 @@ static inline pid_t cspawn_fork (char const *prog, char const *const *argv, char
return pid ;
}
-#ifdef SKALIBS_HASPOSIXSPAWN
+ /*
+ 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))
#include <signal.h>
#include <stdlib.h>
diff --git a/src/sysdeps/trywaitid.c b/src/sysdeps/trywaitid.c
@@ -0,0 +1,12 @@
+/* ISC license. */
+
+#include <sys/types.h>
+#include <signal.h>
+#include <sys/wait.h>
+
+int main (void)
+{
+ siginfo_t info ;
+ waitid(P_PID, 0, &info, WEXITED) ;
+ return 0 ;
+}