blob: f22a222c59d8483aeb871c6f634267d2db94610a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
/* ISC license. */
#include <sys/wait.h>
#include <skalibs/djbunix.h>
/*
wait_pid_nohang (defined here): reaps everything until it gets pid
waitpid_nohang (macro): only tries to reap pid, doesn't touch others
*/
pid_t wait_pid_nohang (pid_t pid, int *wstat)
{
int w = 0 ;
pid_t r = 0 ;
while (r != pid)
{
r = wait_nohang(&w) ;
if (!r || (r == (pid_t)-1)) return r ;
}
*wstat = w ;
return r ;
}
|