summaryrefslogtreecommitdiff
path: root/src/libexecline/el_forx_pidinfo.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libexecline/el_forx_pidinfo.c')
-rw-r--r--src/libexecline/el_forx_pidinfo.c25
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 ;
+}