From: Ross Lagerwall Date: Wed, 14 Dec 2016 07:51:54 +0000 (+0000) Subject: tools/livepatch: Set stdout and stderr unbuffered X-Git-Tag: archive/raspbian/4.11.1-1+rpi1~1^2~66^2~3141 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=a81163ef0fcaeefcf15c561b37255a06ce8e661f;p=xen.git tools/livepatch: Set stdout and stderr unbuffered Using both stdout and stderr interleaved without newlines can result in strange output when using line buffered mode (e.g. a terminal) or when fully buffered (e.g. redirected to a file). Set stdout to unbuffered mode to fix this (stderr is always unbuffered by default). Acked-by: Wei Liu Acked-by: Konrad Rzeszutek Wilk Signed-off-by: Ross Lagerwall --- diff --git a/tools/misc/xen-livepatch.c b/tools/misc/xen-livepatch.c index f6c7c8a629..56ae5aab1c 100644 --- a/tools/misc/xen-livepatch.c +++ b/tools/misc/xen-livepatch.c @@ -330,7 +330,6 @@ int action_func(int argc, char *argv[], unsigned int idx) } printf("."); - fflush(stdout); usleep(DELAY); } while ( ++retry < RETRIES ); @@ -416,6 +415,12 @@ int main(int argc, char *argv[]) { int i, j = 0, ret; + /* + * Set stdout to be unbuffered to avoid having to fflush when + * printing without a newline. + */ + setvbuf(stdout, NULL, _IONBF, 0); + if ( argc <= 1 ) { show_help();