summaryrefslogtreecommitdiffstats
path: root/qarsh.c
diff options
context:
space:
mode:
authorNate Straz <nstraz@redhat.com>2007-01-05 23:09:14 +0000
committerNathan Straz <nstraz@redhat.com>2008-09-23 09:37:46 -0400
commit3a07ad842fcae0f59c449082a0aa6fdf06a9ed35 (patch)
tree62956e985419e2212cea0b49c9ed674717f58c2b /qarsh.c
parenta23532c0b4f1a9bf1bc5a887b9c1a14101c100d2 (diff)
downloadqarsh-3a07ad842fcae0f59c449082a0aa6fdf06a9ed35.tar.gz
qarsh-3a07ad842fcae0f59c449082a0aa6fdf06a9ed35.tar.xz
qarsh-3a07ad842fcae0f59c449082a0aa6fdf06a9ed35.zip
Push processing of the remote command status to main() so it can be
reproduced properly by qarsh. Return 127 as an exit code on internal error cases.
Diffstat (limited to 'qarsh.c')
-rw-r--r--qarsh.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/qarsh.c b/qarsh.c
index 28a1429..bcbd68c 100644
--- a/qarsh.c
+++ b/qarsh.c
@@ -349,20 +349,16 @@ run_remote_cmd(char *cmdline)
if (hbeat_getstate(qarsh_hb) == HOST_TIMEOUT) {
fprintf(stderr, "Didn't receive heartbeat for %d seconds\n",
hbeat_getmaxtimeout(qarsh_hb));
- return 127;
+ return W_EXITCODE(127, 0);
} else if (hbeat_getstate(qarsh_hb) == HOST_REBOOT) {
fprintf(stderr, "Remote host rebooted\n");
- return 127;
+ return W_EXITCODE(127, 0);
}
if (qp == NULL) {
fprintf(stderr, "Remote command exited with unknown state\n");
- return 127;
- }
- if (WIFSIGNALED(qp->qp_cmdexit.qp_status)) {
- rc = 128 + WTERMSIG(qp->qp_cmdexit.qp_status);
- } else {
- rc = WEXITSTATUS(qp->qp_cmdexit.qp_status);
+ return W_EXITCODE(127, 0);
}
+ rc = qp->qp_cmdexit.qp_status;
qpfree(qp);
return rc;
}
@@ -492,5 +488,10 @@ again:
ret = run_remote_cmd(args);
close(qarsh_fd);
free(args);
- return ret;
+ /* If the remote cmd was killed, we need to be killed too */
+ if (WIFSIGNALED(ret)) {
+ raise(WTERMSIG(ret));
+ }
+ /* Otherwise we need to exit with the same exit status */
+ return WEXITSTATUS(ret);
}