skalibs

Mirror/fork of https://skarnet.org/software/skalibs/
git clone https://ccx.te2000.cz/git/skalibs
Log | Files | Refs | README | LICENSE

wait_pid_nohang.c (276B)


      1 /* ISC license. */
      2 
      3 #include <sys/wait.h>
      4 #include <skalibs/djbunix.h>
      5 
      6 pid_t wait_pid_nohang (pid_t pid, int *wstat)
      7 {
      8   int w = 0 ;
      9   pid_t r = 0 ;
     10   while (r != pid)
     11   {
     12     r = wait_nohang(&w) ;
     13     if (!r || (r == (pid_t)-1)) return r ;
     14   }
     15   *wstat = w ;
     16   return r ;
     17 }