summaryrefslogtreecommitdiff
path: root/src/sysdeps
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2023-06-28 21:27:29 +0000
committerLaurent Bercot <ska@appnovation.com>2023-06-28 21:27:29 +0000
commit28e09b5eb76919122f8baf57899154b3dd5fdaa0 (patch)
tree21559ec98d7f0f876fa0e2a5115744e396fd68d0 /src/sysdeps
parentd64a3751ca805c08bfda6a330d73a09e87e993c0 (diff)
downloadskalibs-28e09b5eb76919122f8baf57899154b3dd5fdaa0.tar.xz
Add workaround for bad QoI posix_spawn()
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src/sysdeps')
-rw-r--r--src/sysdeps/tryposixspawnearlyreturn.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/sysdeps/tryposixspawnearlyreturn.c b/src/sysdeps/tryposixspawnearlyreturn.c
new file mode 100644
index 0000000..347f2be
--- /dev/null
+++ b/src/sysdeps/tryposixspawnearlyreturn.c
@@ -0,0 +1,24 @@
+/* ISC license. */
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <spawn.h>
+
+int main (void)
+{
+ posix_spawnattr_t attr ;
+ int e ;
+ char tmp[40] = "./tryposixspawnearlyreturn child:XXXXXX" ;
+ char *argv[2] = { tmp, 0 } ;
+ char *env = 0 ;
+ int fd = mkstemp(tmp) ;
+ if (fd == -1) return 111 ;
+ e = posix_spawnattr_init(&attr) ;
+ if (e) return 111 ;
+ e = posix_spawnattr_setflags(&attr, 0) ;
+ if (e) return 111 ;
+ if (close(fd) == -1 || unlink(tmp) == -1) return 111 ;
+ e = posix_spawn(0, argv[0], 0, &attrp, argv, &env) ;
+ return e ? e == ENOENT ? 1 : 111 : 0 ;
+}