wait_pids_nohang.c (428B)
1 /* ISC license. */ 2 3 #include <sys/wait.h> 4 #include <skalibs/djbunix.h> 5 6 int wait_pids_nohang (pid_t const *pids, unsigned int len, int *wstat) 7 { 8 for (;;) 9 { 10 int w ; 11 pid_t r = wait_nohang(&w) ; 12 if (!r || (r == (pid_t)-1)) return (int)r ; 13 { 14 unsigned int i = 0 ; 15 for (; i < len ; i++) if (r == pids[i]) break ; 16 if (i < len) 17 { 18 *wstat = w ; 19 return 1+i ; 20 } 21 } 22 } 23 }