From: Mihails Strasuns Date: Thu, 19 Jan 2023 10:13:02 +0000 (+0000) Subject: common.h: Flush stdout before writing to stderr X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=db0654e740d96e8a2df36b8b0ecdc9edf26a74c3;p=livepatch-build-tools.git common.h: Flush stdout before writing to stderr 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 Reviewed-by: Ross Lagerwall --- diff --git a/common.h b/common.h index 02c9b7b..9a9da79 100644 --- 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"); \ })