diff options
author | Ed Catmur <ed@catmur.co.uk> | 2008-11-16 12:30:38 +0000 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2008-11-16 12:30:38 +0000 |
commit | b2435fd4fdee8473602affe6cfa720f8231d3188 (patch) | |
tree | 1ca45b6820badd97ecf70ac0a2cf312846777b5a /src | |
parent | libsandbox: implement initial dirfd parsing for *at functions (diff) | |
download | sandbox-b2435fd4fdee8473602affe6cfa720f8231d3188.tar.gz sandbox-b2435fd4fdee8473602affe6cfa720f8231d3188.tar.bz2 sandbox-b2435fd4fdee8473602affe6cfa720f8231d3188.zip |
sandbox: display when a process exits due to a signal
URL: http://bugs.gentoo.org/194943
Signed-off-by: Ed Catmur <ed@catmur.co.uk>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/sandbox.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/sandbox.c b/src/sandbox.c index d77f895..c5bcc6a 100644 --- a/src/sandbox.c +++ b/src/sandbox.c @@ -185,8 +185,9 @@ int spawn_shell(char *argv_bash[], char **env, int debug) /* Child's process */ if (0 == child_pid) { - execve(argv_bash[0], argv_bash, env); - _exit(EXIT_FAILURE); + int ret = execve(argv_bash[0], argv_bash, env); + perror("sandbox: Failed to exec child"); + _exit(ret); } else if (child_pid < 0) { if (debug) fprintf(stderr, "Process failed to spawn!\n"); @@ -199,9 +200,14 @@ int spawn_shell(char *argv_bash[], char **env, int debug) str_list_free(env); ret = waitpid(child_pid, &status, 0); - if ((-1 == ret) || (status > 0)) { - if (debug) - fprintf(stderr, "Process returned with failed exit status!\n"); + if (-1 == ret) { + perror("sandbox: Failed to waitpid for child"); + return 0; + } else if (status != 0) { + if (WIFSIGNALED(status)) + psignal(WTERMSIG(status), "Sandboxed process killed by signal"); + else if (debug) + fprintf(stderr, "Process returned with failed exit status %d!\n", WEXITSTATUS(status)); return 0; } |