14 static struct unreaped *unreaped;
17 static struct unreaped *ualloc (oldptr, n)
18 struct unreaped *oldptr;
21 n *= sizeof (struct unreaped);
25 oldptr = (struct unreaped *) realloc ((char *) oldptr, n);
27 oldptr = (struct unreaped *) malloc (n);
30 fprintf (stderr, "cannot allocate %d bytes\n", n);
36 pid_t waitpid (pid, status, options)
46 unreaped = ualloc (unreaped, 1);
51 for (i = 0; unreaped[i].pid; i++)
52 if (unreaped[i].pid == pid)
54 *status = unreaped[i].status;
55 while (unreaped[i].pid)
57 unreaped[i] = unreaped[i+1];
67 pid_t p = wait3 (status, options, (struct rusage *) 0);
69 pid_t p = wait (status);
72 if (p == 0 || p == -1 || p == pid)
76 unreaped = ualloc (unreaped, n);
77 unreaped[n-1].pid = p;
78 unreaped[n-1].status = *status;