summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDean Jansa <djansa@redhat.com>2005-11-03 20:00:28 +0000
committerNathan Straz <nstraz@redhat.com>2008-09-23 09:37:45 -0400
commitc1f5d5e6feedd6edbcd55da0a5fce4047c351bd2 (patch)
treec346910825fec633489523329cfe29720cb22c00
parentb1888390ff441e1e3a6bd106448d6c0ad3a1a58b (diff)
downloadqarsh-c1f5d5e6feedd6edbcd55da0a5fce4047c351bd2.zip
qarsh-c1f5d5e6feedd6edbcd55da0a5fce4047c351bd2.tar.gz
qarsh-c1f5d5e6feedd6edbcd55da0a5fce4047c351bd2.tar.xz
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.
-rw-r--r--qarsh.c18
1 files 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--;
}