summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNate Straz <nstraz@redhat.com>2006-01-16 22:29:13 +0000
committerNathan Straz <nstraz@redhat.com>2008-09-23 09:37:45 -0400
commit0b5c0f40fc239815e94e064277832c8516d4fe38 (patch)
tree3c13d759e3557c4013c7835fea7ac4e8b782c52b
parent71b0e211a9f865fff608f2619de1a7c18b2ee62d (diff)
downloadqarsh-0b5c0f40fc239815e94e064277832c8516d4fe38.zip
qarsh-0b5c0f40fc239815e94e064277832c8516d4fe38.tar.gz
qarsh-0b5c0f40fc239815e94e064277832c8516d4fe38.tar.xz
Make error messages more useful when there are connection issues
-rw-r--r--qarsh.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/qarsh.c b/qarsh.c
index b593a70..ba32243 100644
--- a/qarsh.c
+++ b/qarsh.c
@@ -87,7 +87,7 @@ sig_handler(int sig)
void
sig_alrm_handler(int sig)
{
- fprintf(stderr, "No heartbeat from remote host\n");
+ fprintf(stderr, "Could not connect to remote host\n");
exit(1);
}
@@ -230,6 +230,7 @@ run_remote_cmd(char *cmdline)
buf = malloc(1024);
memset(buf, 0, 1024);
+ hbeat(qarsh_hb);
cmd_finished = 0;
for (;;) {
if (cmd_finished) {
@@ -247,7 +248,6 @@ run_remote_cmd(char *cmdline)
if (nset == 0) {
if (!hbeat(qarsh_hb)) {
- fprintf(stderr, "No heartbeat from remote host\n");
/* Set our return packet as NULL so we exit
* with unknown error. */
qp = NULL;
@@ -328,9 +328,17 @@ run_remote_cmd(char *cmdline)
}
if (c_out) close(c_out);
if (c_err) close(c_err);
+ free(buf);
+ if (hbeat_getstate(qarsh_hb) == HOST_TIMEOUT) {
+ fprintf(stderr, "Didn't receive heartbeat for %d seconds\n",
+ hbeat_getmaxtimeout(qarsh_hb));
+ return 127;
+ } else if (hbeat_getstate(qarsh_hb) == HOST_REBOOT) {
+ fprintf(stderr, "Remote host rebooted\n");
+ return 127;
+ }
if (qp == NULL) {
fprintf(stderr, "Remote command exited with unknown state\n");
- free(buf);
return 127;
}
if (WIFSIGNALED(qp->qp_cmdexit.qp_status)) {
@@ -339,7 +347,6 @@ run_remote_cmd(char *cmdline)
rc = WEXITSTATUS(qp->qp_cmdexit.qp_status);
}
qpfree(qp);
- free(buf);
return rc;
}