diff options
-rw-r--r-- | qarsh.c | 19 |
1 files changed, 10 insertions, 9 deletions
@@ -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); } |