diff options
Diffstat (limited to 'pkgs/build-support/build-sandbox/src/setup.c')
-rw-r--r-- | pkgs/build-support/build-sandbox/src/setup.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/pkgs/build-support/build-sandbox/src/setup.c b/pkgs/build-support/build-sandbox/src/setup.c index feafd6f6..8a5d29b5 100644 --- a/pkgs/build-support/build-sandbox/src/setup.c +++ b/pkgs/build-support/build-sandbox/src/setup.c @@ -864,9 +864,25 @@ bool setup_sandbox(void) /* Just wait in the parent until the child exits. We need to fork because * otherwise we can't mount /proc in the right PID namespace. */ + int wstatus; if (pid > 0) { - waitpid(pid, NULL, 0); - _exit(1); + + if (waitpid(pid, &wstatus, 0) == -1) { + fputs("sandbox: waitpid failure", stderr); + _exit(EXIT_FAILURE); + } + else if (WIFEXITED(wstatus)) { + _exit(WEXITSTATUS(wstatus)); + } + else if (WIFSIGNALED(wstatus)) { + fprintf(stderr, "sandbox: killed by signal %d\n", WTERMSIG(wstatus)); + _exit(EXIT_FAILURE); + } + else { + // WIFSTOPPED, WIFCONTINUED? + fputs("sandbox: wait failed", stderr); + _exit(EXIT_FAILURE); + } } cached_paths = new_path_cache(); |