From a646c96d5f7ec4b4e0bb538a41fc202c2cdb3309 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Fri, 8 Sep 2023 08:03:58 +0000 Subject: Make child_spawn_workaround public Signed-off-by: Laurent Bercot --- src/libstddjb/child_spawn-internal.h | 16 ---------------- src/libstddjb/child_spawn.c | 4 ---- src/libstddjb/child_spawn0.c | 6 +----- src/libstddjb/child_spawn1_internal.c | 4 ---- src/libstddjb/child_spawn2.c | 4 ---- src/libstddjb/child_spawn3.c | 4 ---- src/libstddjb/child_spawn_workaround.c | 17 ++++++++++++----- src/libstddjb/slurpn.c | 2 +- 8 files changed, 14 insertions(+), 43 deletions(-) delete mode 100644 src/libstddjb/child_spawn-internal.h (limited to 'src/libstddjb') diff --git a/src/libstddjb/child_spawn-internal.h b/src/libstddjb/child_spawn-internal.h deleted file mode 100644 index b0f701c..0000000 --- a/src/libstddjb/child_spawn-internal.h +++ /dev/null @@ -1,16 +0,0 @@ -/* ISC license. */ - -#ifndef CHILD_SPAWN_INTERNAL_H -#define CHILD_SPAWN_INTERNAL_H - -#include - -#ifdef SKALIBS_HASPOSIXSPAWNEARLYRETURN - -#include - -extern pid_t child_spawn_workaround (pid_t, int const *) ; /* closes the pipe */ - -#endif - -#endif diff --git a/src/libstddjb/child_spawn.c b/src/libstddjb/child_spawn.c index e5f5115..7c59fba 100644 --- a/src/libstddjb/child_spawn.c +++ b/src/libstddjb/child_spawn.c @@ -20,10 +20,6 @@ #include #include -#ifdef SKALIBS_HASPOSIXSPAWNEARLYRETURN -# include "child_spawn-internal.h" -#endif - pid_t child_spawn (char const *prog, char const *const *argv, char const *const *envp, int *fds, unsigned int n) { pid_t pid ; diff --git a/src/libstddjb/child_spawn0.c b/src/libstddjb/child_spawn0.c index cfd78f8..ea7a5b1 100644 --- a/src/libstddjb/child_spawn0.c +++ b/src/libstddjb/child_spawn0.c @@ -11,11 +11,7 @@ #include #include - -#ifdef SKALIBS_HASPOSIXSPAWNEARLYRETURN -# include -# include "child_spawn-internal.h" -#endif +#include pid_t child_spawn0 (char const *prog, char const *const *argv, char const *const *envp) { diff --git a/src/libstddjb/child_spawn1_internal.c b/src/libstddjb/child_spawn1_internal.c index 2fe0ee2..9e6eeff 100644 --- a/src/libstddjb/child_spawn1_internal.c +++ b/src/libstddjb/child_spawn1_internal.c @@ -14,10 +14,6 @@ #include -#ifdef SKALIBS_HASPOSIXSPAWNEARLYRETURN -# include "child_spawn-internal.h" -#endif - pid_t child_spawn1_internal (char const *prog, char const *const *argv, char const *const *envp, int *p, int to) { pid_t pid ; diff --git a/src/libstddjb/child_spawn2.c b/src/libstddjb/child_spawn2.c index 44d748f..986fd15 100644 --- a/src/libstddjb/child_spawn2.c +++ b/src/libstddjb/child_spawn2.c @@ -17,10 +17,6 @@ #include -#ifdef SKALIBS_HASPOSIXSPAWNEARLYRETURN -# include "child_spawn-internal.h" -#endif - pid_t child_spawn2 (char const *prog, char const *const *argv, char const *const *envp, int *fds) { pid_t pid ; diff --git a/src/libstddjb/child_spawn3.c b/src/libstddjb/child_spawn3.c index 81ffb0c..6eb7519 100644 --- a/src/libstddjb/child_spawn3.c +++ b/src/libstddjb/child_spawn3.c @@ -19,10 +19,6 @@ #include #include -#ifdef SKALIBS_HASPOSIXSPAWNEARLYRETURN -# include "child_spawn-internal.h" -#endif - pid_t child_spawn3 (char const *prog, char const *const *argv, char const *const *envp, int *fds) { pid_t pid ; diff --git a/src/libstddjb/child_spawn_workaround.c b/src/libstddjb/child_spawn_workaround.c index 516ade5..b5fb4f0 100644 --- a/src/libstddjb/child_spawn_workaround.c +++ b/src/libstddjb/child_spawn_workaround.c @@ -1,6 +1,7 @@ /* ISC license. */ #include +#include #if defined(SKALIBS_HASPOSIXSPAWN) && defined(SKALIBS_HASPOSIXSPAWNEARLYRETURN) @@ -9,8 +10,8 @@ #include #include -#include -#include "child_spawn-internal.h" + + /* when posix_spawn returns too early, you need this */ pid_t child_spawn_workaround (pid_t pid, int const *p) { @@ -41,8 +42,14 @@ pid_t child_spawn_workaround (pid_t pid, int const *p) #else - /* avoid empty TUs */ - -extern int skalibs_child_spawn_workaround_dummy_ ; +pid_t child_spawn_workaround (pid_t pid, int const *p) +{ + if (p) + { + fd_close(p[1]) ; + fd_close(p[0]) ; + } + return pid ; +} #endif diff --git a/src/libstddjb/slurpn.c b/src/libstddjb/slurpn.c index 317e300..d6a20da 100644 --- a/src/libstddjb/slurpn.c +++ b/src/libstddjb/slurpn.c @@ -16,7 +16,7 @@ int slurpn (int fd, stralloc *sa, size_t max) ssize_t r ; size_t n = max && sa->len + N > max ? max - sa->len : N ; if (!n) return (errno = ENOBUFS, 0) ; - if (!stralloc_readyplus(sa, n)) break ; + if (!stralloc_readyplus(sa, n)) return 0 ; r = fd_read(fd, sa->s + sa->len, n) ; switch (r) { -- cgit v1.2.3