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 <wei.liu2@citrix.com>
Acked-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
This commit is contained in:
Ross Lagerwall authored and Konrad Rzeszutek Wilk committed 2016-12-14 15:27:19 -05:00
1 parent 181deca063
commit a81163ef0f
1 file changed
+6 -1
+6 -1
View File
@@ -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();
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.