diff options
author | Dean Jansa <djansa@redhat.com> | 2005-11-03 20:00:28 +0000 |
---|---|---|
committer | Nathan Straz <nstraz@redhat.com> | 2008-09-23 09:37:45 -0400 |
commit | c1f5d5e6feedd6edbcd55da0a5fce4047c351bd2 (patch) | |
tree | c346910825fec633489523329cfe29720cb22c00 /qarsh.c | |
parent | b1888390ff441e1e3a6bd106448d6c0ad3a1a58b (diff) | |
download | qarsh-c1f5d5e6feedd6edbcd55da0a5fce4047c351bd2.tar.gz qarsh-c1f5d5e6feedd6edbcd55da0a5fce4047c351bd2.tar.xz qarsh-c1f5d5e6feedd6edbcd55da0a5fce4047c351bd2.zip |
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.
Diffstat (limited to 'qarsh.c')
-rw-r--r-- | qarsh.c | 18 |
1 files changed, 15 insertions, 3 deletions
@@ -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--; } |