]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
Flush chronyc output buffers.
authorPaul Elliott <pelliott@io.com>
Mon, 5 Dec 2005 07:16:26 +0000 (01:16 -0600)
committerRichard P. Curnow <rc@rc0.org.uk>
Sun, 29 Jan 2006 23:31:56 +0000 (23:31 +0000)
The following is a patch to chronyc that causes it
to flush the buffers to stderr and stdout after
executing each command. This is needed if
you are controling chronyc from a program (i.e. chronyc's
input and output descriptors are pipes which are being
written/read by another program) and
you do not want to block waiting for chronyc response
which is trapped in a buffer!

client.c

index 424877c731ba0a2a3ee9061d8a49415caa310ed5..a1d18d75f45e654052093bacb804333e6acc23ad 100644 (file)
--- a/client.c
+++ b/client.c
@@ -2319,7 +2319,11 @@ process_line(char *line)
   /* Check for line being blank */
   p = line;
   while (*p && isspace((unsigned char)*p)) p++;
-  if (!*p) return quit;
+  if (!*p) {
+    fflush(stderr);
+    fflush(stdout);
+    return quit;
+  };
 
   if (!strncmp(p, "offline", 7)) {
     do_normal_submit = process_cmd_offline(&tx_message, p+7);
@@ -2480,7 +2484,8 @@ process_line(char *line)
       }
     }
   }
-
+  fflush(stderr);
+  fflush(stdout);
   return quit;
 }