I read this code in an implementation of the system function of unix (problem 8.22):
int status;
if (wait(&status) > 0) {
if (WIFEXITED(status)) {
return WEXITSTATUS(status);
} else {
return status;
}
}
I don't understand what the if condition is for here: Isn't the status returned by WEXITSTATUS the same as the one in wait? If not, then what is the difference between the two?