linux-sysprog · intermediate · ~15 min
Decode the wait status bitfield.
wait fills a status word. Emulate WEXITSTATUS: implement int exit_code(int wstatus) returning the child's exit code, which is bits 8-15 of wstatus ((wstatus >> 8) & 0xFF).
int exit_code(int wstatus) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.