]> xenbits.xensource.com Git - livepatch-build-tools.git/commitdiff
common.h: Flush stdout before writing to stderr
authorMihails Strasuns <mstrasun@amazon.com>
Thu, 19 Jan 2023 10:13:02 +0000 (10:13 +0000)
committerRoss Lagerwall <ross.lagerwall@citrix.com>
Mon, 20 Feb 2023 11:25:14 +0000 (11:25 +0000)
Flush existing debug messages before writing an error to stderr.  stderr
is usually unbuffered and stdout is usually buffered. This results in
odd looking output when an error occurs and both stderr/stdout are
printed on the same console/file. More precisely, the error message is
printed in the middle of previously emitted debug messages.

Signed-off-by: Michael Kurth <mku@amazon.com>
Reviewed-by: Ross Lagerwall <ross.lagerwall@citrix.com>
common.h

index 02c9b7bec3e7ea1690f850b86ba68f8d7d9b8fe7..9a9da791a33fb4f5ab4275bf4b8cea98921a09c0 100644 (file)
--- a/common.h
+++ b/common.h
@@ -10,6 +10,7 @@ extern char *childobj;
 
 #define DIFF_FATAL(format, ...) \
 ({ \
+       fflush(stdout); \
        fprintf(stderr, "ERROR: %s: " format "\n", childobj, ##__VA_ARGS__); \
        error(2, 0, "unreconcilable difference"); \
 })