From c1f5d5e6feedd6edbcd55da0a5fce4047c351bd2 Mon Sep 17 00:00:00 2001 From: Dean Jansa Date: Thu, 3 Nov 2005 20:00:28 +0000 Subject: Set a flag when a command finishes rather than exiting the select loop. There may still be output to be read even after the command completed. --- qarsh.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/qarsh.c b/qarsh.c index 5780e95..4df34a0 100644 --- a/qarsh.c +++ b/qarsh.c @@ -147,6 +147,7 @@ run_remote_cmd(char *cmdline) struct sockaddr_in caddr; socklen_t clen; struct timespec timeout; + short cmd_finished; l_in = bind_any(QARSH_MINPORT); p_in = getsockport(l_in); @@ -225,9 +226,15 @@ run_remote_cmd(char *cmdline) buf = malloc(1024); memset(buf, 0, 1024); + cmd_finished = 0; for (;;) { - timeout.tv_sec = 5; - timeout.tv_nsec = 0; + if (cmd_finished) { + timeout.tv_sec = 0; + timeout.tv_nsec = 0; + } else { + timeout.tv_sec = 5; + timeout.tv_nsec = 0; + } testfds = readfds; memset(buf, 0, 1024); @@ -242,6 +249,10 @@ run_remote_cmd(char *cmdline) qp = NULL; break; } + + if (cmd_finished) { + break; + } continue; } @@ -304,7 +315,8 @@ run_remote_cmd(char *cmdline) /* dump_qp(qp); */ if (qp && qp->qp_type == QP_CMDEXIT) { - break; + cmd_finished = 1; + /* break; */ } nset--; } -- cgit