- LIST_FOR_EACH (p, struct process, node, &all_processes) {
- if (p->pid == pid) {
+ LIST_FOR_EACH (p, struct process, node, &all_processes) {
+ if (!p->exited) {
+ int retval, status;
+ do {
+ retval = waitpid(p->pid, &status, WNOHANG);
+ } while (retval == -1 && errno == EINTR);
+ if (retval == p->pid) {