diff options
author | Nate Straz <nstraz@redhat.com> | 2006-01-16 22:29:13 +0000 |
---|---|---|
committer | Nathan Straz <nstraz@redhat.com> | 2008-09-23 09:37:45 -0400 |
commit | 0b5c0f40fc239815e94e064277832c8516d4fe38 (patch) | |
tree | 3c13d759e3557c4013c7835fea7ac4e8b782c52b /qarsh.c | |
parent | 71b0e211a9f865fff608f2619de1a7c18b2ee62d (diff) | |
download | qarsh-0b5c0f40fc239815e94e064277832c8516d4fe38.tar.gz qarsh-0b5c0f40fc239815e94e064277832c8516d4fe38.tar.xz qarsh-0b5c0f40fc239815e94e064277832c8516d4fe38.zip |
Make error messages more useful when there are connection issues
Diffstat (limited to 'qarsh.c')
-rw-r--r-- | qarsh.c | 15 |
1 files changed, 11 insertions, 4 deletions
@@ -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; } |