summaryrefslogtreecommitdiff
path: root/src/libstddjb/wait_pid_nohang.c
blob: 7b27bbe012fa90ca4b6c4a8d3f7de95f2a021e4e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/* ISC license. */

#include <sys/wait.h>
#include <skalibs/djbunix.h>

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 ;
}