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

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

pid_t wait_pid_nohang (pid_t pid, int *wstat)
{
  int w = 0 ;
  register pid_t r = 0 ;
  while (r != pid)
  {
    r = wait_nohang(&w) ;
    if (!r || (r == (pid_t)-1)) return (int)r ;
  }
  *wstat = w ;
  return r ;
}