diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2018-07-08 14:23:03 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2018-07-08 14:23:03 -0400 |
commit | 9caf477f12e730af5181587656f34c316152a2a6 (patch) | |
tree | 5323fde37be424f24d89e521ac57addacbae5f1a /exec.c | |
parent | 1fbd9806320f6f7d23d5d49100dfa6cb322b68b5 (diff) | |
download | bfs-9caf477f12e730af5181587656f34c316152a2a6.tar.xz |
exec: Add some debugging info about failed commands
Diffstat (limited to 'exec.c')
-rw-r--r-- | exec.c | 24 |
1 files changed, 19 insertions, 5 deletions
@@ -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; } |