diff options
author | Amitay Isaacs <amitay@gmail.com> | 2016-11-21 17:38:18 +1100 |
---|---|---|
committer | Amitay Isaacs <amitay@samba.org> | 2016-12-18 14:23:22 +0100 |
commit | b2b8f1eaed4a50ad2bcd391fef3b66a1ff6e9bfa (patch) | |
tree | b5c9470365b89b573f1db1205ec395de5d5b35b7 /ctdb/tools | |
parent | 590acdc5294eb12259b0112b230418faab575edb (diff) | |
download | samba-b2b8f1eaed4a50ad2bcd391fef3b66a1ff6e9bfa.tar.gz |
ctdb-tool: Improve error reporting if helper execution fails
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
Diffstat (limited to 'ctdb/tools')
-rw-r--r-- | ctdb/tools/ctdb.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/ctdb/tools/ctdb.c b/ctdb/tools/ctdb.c index dffc103dbe1..4c03b5c1e95 100644 --- a/ctdb/tools/ctdb.c +++ b/ctdb/tools/ctdb.c @@ -676,10 +676,10 @@ static int run_helper(TALLOC_CTX *mem_ctx, const char *command, if (pid == 0) { ret = execv(path, discard_const(new_argv)); if (ret == -1) { - _exit(errno); + _exit(64+errno); } /* Should not happen */ - _exit(ENOEXEC); + _exit(64+ENOEXEC); } talloc_free(new_argv); @@ -693,11 +693,20 @@ static int run_helper(TALLOC_CTX *mem_ctx, const char *command, } if (WIFEXITED(status)) { - ret = WEXITSTATUS(status); + int pstatus = WEXITSTATUS(status); + if (WIFSIGNALED(status)) { + fprintf(stderr, "%s terminated with signal %d\n", + command, WTERMSIG(status)); + ret = EINTR; + } else if (pstatus >= 64 && pstatus < 255) { + fprintf(stderr, "%s failed with error %d\n", + command, pstatus-64); + ret = pstatus - 64; + } else { + ret = pstatus; + } return ret; - } - - if (WIFSIGNALED(status)) { + } else if (WIFSIGNALED(status)) { fprintf(stderr, "%s terminated with signal %d\n", command, WTERMSIG(status)); return EINTR; |