diff options
-rw-r--r-- | qarsh.c | 49 |
1 files changed, 41 insertions, 8 deletions
@@ -182,6 +182,7 @@ int run_remote_cmd(char *cmdline) { struct qa_packet *qp; + int ret; int rc; int allowed_in = 0; /* bytes we can send to qarshd */ char b_out[QARSH_BUFSIZE], b_err[QARSH_BUFSIZE]; /* Buffers */ @@ -196,19 +197,31 @@ run_remote_cmd(char *cmdline) short stdin_isatty = isatty(fileno(stdin)); qp = make_qp_runcmd(cmdline); - send_packet(qarsh_fd, qp); + ret = send_packet(qarsh_fd, qp); qpfree(qp); + if (ret == -1) { + fprintf(stderr, "Failed to send runcmd packet: %s\n", strerror(errno)); + exit(125); + } /* Setup signal handling stuff so we can propogate signals */ setup_signals(); /* Tell qarshd how much data it can send on stdout and stderr */ qp = make_qp_data_allow(1, QARSH_BUFSIZE); - send_packet(qarsh_fd, qp); + ret = send_packet(qarsh_fd, qp); qpfree(qp); + if (ret == -1) { + fprintf(stderr, "Failed to send data allow packet: %s\n", strerror(errno)); + exit(125); + } qp = make_qp_data_allow(2, QARSH_BUFSIZE); - send_packet(qarsh_fd, qp); + ret = send_packet(qarsh_fd, qp); qpfree(qp); + if (ret == -1) { + fprintf(stderr, "Failed to send data allow packet: %s\n", strerror(errno)); + exit(125); + } hbeat(qarsh_hb); cmd_finished = 0; @@ -228,7 +241,11 @@ run_remote_cmd(char *cmdline) /* close stdin if it is a tty */ if (stdin_isatty) { qp = make_qp_data(0, 0, 0, NULL); - send_packet(qarsh_fd, qp); + ret = send_packet(qarsh_fd, qp); + if (ret == -1) { + fprintf(stderr, "Failed to send data packet: %s\n", strerror(errno)); + exit(125); + } qpfree(qp); close(fileno(stdin)); allowed_in = -1; @@ -258,7 +275,11 @@ run_remote_cmd(char *cmdline) /* Only test signals */ if (signal_to_send) { qp = make_qp_kill(signal_to_send); - send_packet(qarsh_fd, qp); + ret = send_packet(qarsh_fd, qp); + if (ret == -1) { + fprintf(stderr, "Failed to send kill packet: %s\n", strerror(errno)); + exit(125); + } qpfree(qp); signal_to_send = 0; } @@ -273,7 +294,11 @@ run_remote_cmd(char *cmdline) nbytes = read(fileno(stdin), buf, allowed_in); if (nbytes >= 0) { qp = make_qp_data(0, 0, nbytes, buf); - send_packet(qarsh_fd, qp); + ret = send_packet(qarsh_fd, qp); + if (ret == -1) { + fprintf(stderr, "Failed to send data packet: %s\n", strerror(errno)); + exit(125); + } qpfree(qp); allowed_in -= nbytes; if (nbytes == 0) { @@ -296,7 +321,11 @@ run_remote_cmd(char *cmdline) } if (!eof_out) { qp = make_qp_data_allow(1, nbytes); - send_packet(qarsh_fd, qp); + ret = send_packet(qarsh_fd, qp); + if (ret == -1) { + fprintf(stderr, "Failed to send data allow packet: %s\n", strerror(errno)); + exit(125); + } qpfree(qp); } nset--; @@ -312,7 +341,11 @@ run_remote_cmd(char *cmdline) } if (!eof_err) { qp = make_qp_data_allow(2, nbytes); - send_packet(qarsh_fd, qp); + ret = send_packet(qarsh_fd, qp); + if (ret == -1) { + fprintf(stderr, "Failed to send data allow packet: %s\n", strerror(errno)); + exit(125); + } qpfree(qp); } nset--; |