mirror of https://gitlab.com/nakst/essence
return exit status in change_sysroot
This commit is contained in:
parent
7791069281
commit
e95c9fb15f
|
@ -100,7 +100,7 @@ int main(int argc, char **argv) {
|
||||||
basePID = pid;
|
basePID = pid;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (kill(basePID, 0) == 0 /* still alive */) {
|
while (true) {
|
||||||
struct user_regs_struct registers = { 0 };
|
struct user_regs_struct registers = { 0 };
|
||||||
|
|
||||||
pid_t pid = waitpid(-1, 0, 0);
|
pid_t pid = waitpid(-1, 0, 0);
|
||||||
|
@ -161,15 +161,18 @@ int main(int argc, char **argv) {
|
||||||
printf("unhandled syscall %llu\n", registers.orig_rax);
|
printf("unhandled syscall %llu\n", registers.orig_rax);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int status;
|
||||||
ptrace(PTRACE_SYSCALL, pid, 0, 0);
|
ptrace(PTRACE_SYSCALL, pid, 0, 0);
|
||||||
waitpid(pid, 0, 0);
|
waitpid(pid, &status, 0);
|
||||||
|
|
||||||
if (ptrace(PTRACE_GETREGS, pid, 0, ®isters) == -1) {
|
if (ptrace(PTRACE_GETREGS, pid, 0, ®isters) == -1) {
|
||||||
// The process has likely exited.
|
// The process has exited.
|
||||||
|
|
||||||
|
if (pid == basePID) {
|
||||||
|
return WEXITSTATUS(status);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
ptrace(PTRACE_SYSCALL, pid, 0, 0);
|
ptrace(PTRACE_SYSCALL, pid, 0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue