diff options
| author | Laurent Bercot <ska-skaware@skarnet.org> | 2024-11-06 08:05:33 +0000 |
|---|---|---|
| committer | Laurent Bercot <ska@appnovation.com> | 2024-11-06 08:05:33 +0000 |
| commit | 3d91d9ce645efa020800b85be1ac2727ebcbad19 (patch) | |
| tree | 4461d2c99abfb80f3955b4f775b26767e823fc6a /src/libexecline/el_forx_pidinfo.c | |
| parent | 32ed930a967c83c5b683d1d22c286b46a9f792ea (diff) | |
| download | execline-3d91d9ce645efa020800b85be1ac2727ebcbad19.tar.gz | |
Prepare for 2.9.7.0 ; rework forx/forstdin -p, add -P maxpar
Also refactor several things to keep global footprint low
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src/libexecline/el_forx_pidinfo.c')
| -rw-r--r-- | src/libexecline/el_forx_pidinfo.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/libexecline/el_forx_pidinfo.c b/src/libexecline/el_forx_pidinfo.c new file mode 100644 index 0000000..61c5a26 --- /dev/null +++ b/src/libexecline/el_forx_pidinfo.c @@ -0,0 +1,25 @@ +/* ISC license. */ + +#include <skalibs/djbunix.h> + +#include <execline/execline.h> + +el_forx_pidinfo_t *el_forx_pidinfo = 0 ; + +int el_forx_isok (unsigned short const *tab, unsigned int n, unsigned short code) +{ + unsigned int i = 0 ; + for (; i < n ; i++) if (code == tab[i]) break ; + return i < n ; +} + +void el_forx_sigchld_handler (int sig) +{ + for (;;) + { + ssize_t r = wait_pids_nohang(el_forx_pidinfo->tab, el_forx_pidinfo->len, &el_forx_pidinfo->wstat) ; + if (r <= 0) break ; + el_forx_pidinfo->tab[r-1] = el_forx_pidinfo->tab[--el_forx_pidinfo->len] ; + } + (void)sig ; +} |
