| 123 |
|
) |
| 124 |
|
{ |
| 125 |
|
int togo = nproc; |
| 126 |
< |
int status, rtn_status = 0; |
| 126 |
> |
int status = 0, rtn_status = 0; |
| 127 |
|
RT_PID pid; |
| 128 |
|
int i; |
| 129 |
|
|
| 135 |
|
} else |
| 136 |
|
togo -= (pd[i].pid < 0); |
| 137 |
|
if (nproc == 1) { /* await specific process? */ |
| 138 |
– |
status = 0; |
| 138 |
|
if (waitpid(pd->pid, &status, 0) != pd->pid) |
| 139 |
|
return(-1); |
| 140 |
|
*pd = sp_inactive; |
| 143 |
|
/* else unordered wait */ |
| 144 |
|
while (togo > 0 && (pid = wait(&status)) >= 0) { |
| 145 |
|
for (i = nproc; i-- > 0; ) |
| 146 |
< |
if (pd[i].pid == pid) { |
| 147 |
< |
pd[i] = sp_inactive; |
| 149 |
< |
--togo; |
| 150 |
< |
break; |
| 151 |
< |
} |
| 146 |
> |
if (pd[i].pid == pid) |
| 147 |
> |
break; /* found it! */ |
| 148 |
|
if (i < 0) |
| 149 |
< |
continue; /* child we don't know? */ |
| 149 |
> |
continue; /* or child not in our list */ |
| 150 |
> |
pd[i] = sp_inactive; |
| 151 |
> |
--togo; |
| 152 |
|
status = status>>8 & 0xff; |
| 153 |
|
if (status) /* record non-zero status */ |
| 154 |
|
rtn_status = status; |