libguestfs/SOURCES/0022-common-mltools-make-sure-machine-readable-output-is-.patch

35 lines
1.0 KiB
Diff

From d60ef2eca9c0e51944a9c17806d6936af45907f5 Mon Sep 17 00:00:00 2001
From: Pino Toscano <ptoscano@redhat.com>
Date: Fri, 22 Mar 2019 11:36:41 +0100
Subject: [PATCH] common/mltools: make sure machine readable output is flushed
Enhance the helper printf function for machine readable output to always
flush after each string: this way, readers of the machine readable
stream can get the output as soon as it is outputted.
(cherry picked from commit abf1607f46ddc3d829a3688b9499a9bcd2319d19)
---
common/mltools/tools_utils.ml | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/common/mltools/tools_utils.ml b/common/mltools/tools_utils.ml
index 5a35708cd..ade4cb37f 100644
--- a/common/mltools/tools_utils.ml
+++ b/common/mltools/tools_utils.ml
@@ -59,7 +59,11 @@ let machine_readable () =
| None -> None
| Some chan ->
let pr fs =
- ksprintf (output_string chan) fs
+ let out s =
+ output_string chan s;
+ flush chan
+ in
+ ksprintf out fs
in
Some { pr }
--
2.18.4