ucspi-ssl  0.99e
TLS encryption for IPv6 communication
wait_pid.c
Go to the documentation of this file.
1 /* Public domain. */
2 
3 #include <sys/types.h>
4 #include <sys/wait.h>
5 #include "error.h"
6 #include "haswaitp.h"
7 
8 #ifdef HASWAITPID
9 
10 int wait_pid(wstat,pid) int *wstat; int pid;
11 {
12  int r;
13 
14  do
15  r = waitpid(pid,wstat,0);
16  while ((r == -1) && (errno == error_intr));
17  return r;
18 }
19 
20 #else
21 
22 /* XXX untested */
23 /* XXX breaks down with more than two children */
24 static int oldpid = 0;
25 static int oldwstat; /* defined if(oldpid) */
26 
27 int wait_pid(wstat,pid) int *wstat; int pid;
28 {
29  int r;
30 
31  if (pid == oldpid) { *wstat = oldwstat; oldpid = 0; return pid; }
32 
33  do {
34  r = wait(wstat);
35  if ((r != pid) && (r != -1)) { oldwstat = *wstat; oldpid = r; continue; }
36  }
37  while ((r == -1) && (errno == error_intr));
38  return r;
39 }
40 
41 #endif
int wait_pid(int *wstat, int pid)
Definition: wait_pid.c:27
int error_intr
Definition: error.c:8