diff options
| author | Laurent Bercot <ska-skaware@skarnet.org> | 2026-08-31 23:45:35 +0000 |
|---|---|---|
| committer | Laurent Bercot <ska-skaware@skarnet.org> | 2026-08-31 23:45:35 +0000 |
| commit | 233e3ccb96525e7a6af31a60b891badd8d73c5a4 (patch) | |
| tree | e3232d7a7364537e76121e516abf6ef307191db2 /src/libstddjb/waitpids_nohang.c | |
| parent | 4f42e46eff746603a0762c0299cc63d9c7004bcf (diff) | |
| download | skalibs-main.tar.gz | |
Add pthread_create_flat, waitpid_nohang, waitpids_nohang
Diffstat (limited to 'src/libstddjb/waitpids_nohang.c')
| -rw-r--r-- | src/libstddjb/waitpids_nohang.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/libstddjb/waitpids_nohang.c b/src/libstddjb/waitpids_nohang.c new file mode 100644 index 0000000..23f03de --- /dev/null +++ b/src/libstddjb/waitpids_nohang.c @@ -0,0 +1,19 @@ +/* ISC license. */ + +#include <sys/wait.h> +#include <skalibs/djbunix.h> + + /* + waitpids_nohang (defined here): only reap pids, don't touch the rest + */ + +int waitpids_nohang (pid_t const *pids, unsigned int len, int *wstat) +{ + for (unsigned int i = 0 ; i < len ; i++) + { + pid_t r = waitpid_nohang(pids[i], wstat) ; + if (r == -1) return -1-i ; + else if (r == pids[i]) return 1+i ; + } + return 0 ; +} |
