From a58812d5404844274298344babdb079e161d164f Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Fri, 16 Oct 2026 07:12:56 +0000 Subject: Prepare for 2.16.0.0, remove waitn*, change openslurpclose_at --- src/include/skalibs/djbunix.h | 6 ------ src/include/skalibs/unix-transactional.h | 3 ++- src/libstddjb/waitn.c | 11 ----------- src/libstddjb/waitn_posix.c | 21 --------------------- src/libstddjb/waitn_reap.c | 11 ----------- src/libstddjb/waitn_reap_posix.c | 22 ---------------------- src/libunixonacid/openslurpclose_at.c | 17 ----------------- src/libunixonacid/openslurpnclose_at.c | 17 +++++++++++++++++ 8 files changed, 19 insertions(+), 89 deletions(-) delete mode 100644 src/libstddjb/waitn.c delete mode 100644 src/libstddjb/waitn_posix.c delete mode 100644 src/libstddjb/waitn_reap.c delete mode 100644 src/libstddjb/waitn_reap_posix.c delete mode 100644 src/libunixonacid/openslurpclose_at.c create mode 100644 src/libunixonacid/openslurpnclose_at.c (limited to 'src') diff --git a/src/include/skalibs/djbunix.h b/src/include/skalibs/djbunix.h index 0bba29a..51be4aa 100644 --- a/src/include/skalibs/djbunix.h +++ b/src/include/skalibs/djbunix.h @@ -74,13 +74,7 @@ extern pid_t wait_nointr (int *) ; #define wait_nohang(wstat) waitpid_nohang(-1, (wstat)) extern pid_t wait_pid_nohang (pid_t, int *) ; extern int wait_pids_nohang (pid_t const *, unsigned int, int *) ; - -/* These will disappear or be refactored */ extern unsigned int wait_reap (void) ; -extern int waitn (pid_t *, unsigned int) ; -extern int waitn_posix (pid_t *, unsigned int, int *) ; -extern int waitn_reap (pid_t *, unsigned int) ; -extern int waitn_reap_posix (pid_t *, unsigned int, int *) ; extern int fd_chdir (int) ; diff --git a/src/include/skalibs/unix-transactional.h b/src/include/skalibs/unix-transactional.h index 9b884f9..ae8a263 100644 --- a/src/include/skalibs/unix-transactional.h +++ b/src/include/skalibs/unix-transactional.h @@ -40,7 +40,8 @@ extern int openc_appendat (int, char const *) ; extern int openc_appendatb (int, char const *) ; extern ssize_t openreadnclose_at (int, char const *, char *, size_t) ; -extern int openslurpclose_at (int, char const *, stralloc *) ; +#define openslurpclose_at(dirfd, fn, sa) openslurpnclose_at(dirfd, fn, (sa), 0) +extern int openslurpnclose_at (int, char const *, stralloc *, size_t) ; extern int opengetlnclose_at (int, char const *, stralloc *, int) ; extern size_t openwritenclose_at (int, char const *, char const *, size_t) ; diff --git a/src/libstddjb/waitn.c b/src/libstddjb/waitn.c deleted file mode 100644 index 4d980cc..0000000 --- a/src/libstddjb/waitn.c +++ /dev/null @@ -1,11 +0,0 @@ -/* ISC license. */ - -#include - -#include - -int waitn (pid_t *pids, unsigned int n) -{ - int dummy ; - return waitn_posix(pids, n, &dummy) ; -} diff --git a/src/libstddjb/waitn_posix.c b/src/libstddjb/waitn_posix.c deleted file mode 100644 index ea5935d..0000000 --- a/src/libstddjb/waitn_posix.c +++ /dev/null @@ -1,21 +0,0 @@ -/* ISC license. */ - -#include - -#include - -int waitn_posix (pid_t *pids, unsigned int n, int *w) -{ - pid_t wanted = n ? pids[n-1] : 0 ; - while (n) - { - int wstat ; - unsigned int i = 0 ; - pid_t pid = wait_nointr(&wstat) ; - if (pid < 0) return 0 ; - for (; i < n ; i++) if (pid == pids[i]) break ; - if (i < n) pids[i] = pids[--n] ; - if (pid == wanted) *w = wstat ; - } - return 1 ; -} diff --git a/src/libstddjb/waitn_reap.c b/src/libstddjb/waitn_reap.c deleted file mode 100644 index 2c4ebe8..0000000 --- a/src/libstddjb/waitn_reap.c +++ /dev/null @@ -1,11 +0,0 @@ -/* ISC license. */ - -#include - -#include - -int waitn_reap (pid_t *pids, unsigned int len) -{ - int dummy ; - return waitn_reap_posix(pids, len, &dummy) ; -} diff --git a/src/libstddjb/waitn_reap_posix.c b/src/libstddjb/waitn_reap_posix.c deleted file mode 100644 index 4a6994f..0000000 --- a/src/libstddjb/waitn_reap_posix.c +++ /dev/null @@ -1,22 +0,0 @@ -/* ISC license. */ - -#include - -#include - -int waitn_reap_posix (pid_t *pids, unsigned int len, int *w) -{ - pid_t wanted = len ? pids[len-1] : 0 ; - unsigned int n = 0 ; - while (len) - { - int wstat ; - int r = wait_pids_nohang(pids, len, &wstat) ; - if (r < 0) return r ; - else if (!r) break ; - if (pids[r-1] == wanted) *w = wstat ; - pids[r-1] = pids[--len] ; - n++ ; - } - return n ; -} diff --git a/src/libunixonacid/openslurpclose_at.c b/src/libunixonacid/openslurpclose_at.c deleted file mode 100644 index 4ab6fa5..0000000 --- a/src/libunixonacid/openslurpclose_at.c +++ /dev/null @@ -1,17 +0,0 @@ -/* ISC license. */ - -#include -#include - -int openslurpclose_at (int dirfd, char const *fn, stralloc *sa) -{ - int fd = openc_readatb(dirfd, fn) ; - if (fd < 0) return 0 ; - if (!slurp(sa, fd)) - { - fd_close(fd) ; - return 0 ; - } - fd_close(fd) ; - return 1 ; -} diff --git a/src/libunixonacid/openslurpnclose_at.c b/src/libunixonacid/openslurpnclose_at.c new file mode 100644 index 0000000..8880a71 --- /dev/null +++ b/src/libunixonacid/openslurpnclose_at.c @@ -0,0 +1,17 @@ +/* ISC license. */ + +#include +#include + +int openslurpnclose_at (int dirfd, char const *fn, stralloc *sa, size_t n) +{ + int fd = openc_readatb(dirfd, fn) ; + if (fd < 0) return 0 ; + if (!slurpn(fd, sa, n)) + { + fd_close(fd) ; + return 0 ; + } + fd_close(fd) ; + return 1 ; +} -- cgit v1.3.1