in init/init.c [301:319]
int reap_until(pid_t until_pid) {
for (;;) {
int status;
pid_t pid = wait(&status);
die_on(pid < 0, "wait");
if (pid == until_pid) {
// The initial child process died. Pass through the exit status.
if (WIFEXITED(status)) {
if (WEXITSTATUS(status) != 0) {
fputs("child exited with error\n", stderr);
}
return WEXITSTATUS(status);
}
fputs("child exited by signal\n", stderr);
return 128 + WTERMSIG(status);
}
}
}