summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2018-07-08 14:23:03 -0400
committerTavian Barnes <tavianator@tavianator.com>2018-07-08 14:23:03 -0400
commit9caf477f12e730af5181587656f34c316152a2a6 (patch)
tree5323fde37be424f24d89e521ac57addacbae5f1a
parent1fbd9806320f6f7d23d5d49100dfa6cb322b68b5 (diff)
downloadbfs-9caf477f12e730af5181587656f34c316152a2a6.tar.xz
exec: Add some debugging info about failed commands
-rw-r--r--exec.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/exec.c b/exec.c
index d383935..43ffad0 100644
--- a/exec.c
+++ b/exec.c
@@ -363,17 +363,28 @@ static int bfs_exec_spawn(const struct bfs_exec *execbuf) {
return -1;
}
- int status;
- if (waitpid(pid, &status, 0) < 0) {
+ int wstatus;
+ if (waitpid(pid, &wstatus, 0) < 0) {
return -1;
}
errno = 0;
- if (WIFEXITED(status) && WEXITSTATUS(status) == EXIT_SUCCESS) {
- return 0;
+
+ if (WIFEXITED(wstatus)) {
+ int status = WEXITSTATUS(wstatus);
+ if (status == EXIT_SUCCESS) {
+ return 0;
+ } else {
+ bfs_exec_debug(execbuf, "Command '%s' failed with status %d\n", execbuf->argv[0], status);
+ }
+ } else if (WIFSIGNALED(wstatus)) {
+ int sig = WTERMSIG(wstatus);
+ bfs_exec_debug(execbuf, "Command '%s' terminated by signal %d\n", execbuf->argv[0], sig);
} else {
- return -1;
+ bfs_exec_debug(execbuf, "Command '%s' terminated abnormally\n", execbuf->argv[0]);
}
+
+ return -1;
} else {
// Child
close(pipefd[0]);
@@ -601,6 +612,9 @@ int bfs_exec_finish(struct bfs_exec *execbuf) {
while (bfs_exec_args_remain(execbuf)) {
execbuf->ret |= bfs_exec_flush(execbuf);
}
+ if (execbuf->ret != 0) {
+ bfs_exec_debug(execbuf, "One or more executions of '%s' failed\n", execbuf->argv[0]);
+ }
}
return execbuf->ret;
}