blob: f56c065a448eca5beb221db51c2e9c9094bfc24c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
/* ISC license. */
#include <sys/wait.h>
#include <skalibs/djbunix.h>
/*
wait_pids_nohang (with the underscore): reap everything, report if in pids
*/
int wait_pids_nohang (pid_t const *pids, unsigned int len, int *wstat)
{
for (;;)
{
int w ;
pid_t r = wait_nohang(&w) ;
if (!r || (r == (pid_t)-1)) return (int)r ;
{
unsigned int i = 0 ;
for (; i < len ; i++) if (r == pids[i]) break ;
if (i < len)
{
*wstat = w ;
return 1+i ;
}
}
}
}
|