linux-sysprog · intermediate · ~15 min
`fork`, `_exit`, `waitpid`; the parent/child split.
Implement int spawn_exit(int code) that:
_exit(code),waitpid()s for the child and returns the child's exit status (the value extracted by WEXITSTATUS).#include <unistd.h>
#include <sys/wait.h>
int spawn_exit(int code) {
/* TODO */
return -1;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.