From d1828b32e00bbd6fe3dee3bdfafb6adf62a9dabc Mon Sep 17 00:00:00 2001 From: Sergei Trofimovich Date: Sat, 29 Jan 2022 10:11:19 +0000 Subject: [PATCH] hello: force stdout buffering until atexit() Before the change atexit-1 test failed on musl libc. test assumed that actual I/O to stdout will happen at atexit() call and not before. But musl performed I/O earlier and did not buffer any data. To maintain the assumption of buffered I/O the change enables full buffering for stdout with enough buffer to hold all potential output. * main: set full buffering on stdout. --- src/hello.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/hello.c b/src/hello.c index 2e7d38e..715a3bb 100644 --- a/src/hello.c +++ b/src/hello.c @@ -134,6 +134,9 @@ main (int argc, char *argv[]) mbstate_t mbstate = { 0, }; size_t len; + /* Make sure real I/O will not happen until atexit(). */ + setvbuf(stdout, NULL, _IOFBF, 1024); + set_program_name (argv[0]); /* Set locale via LC_ALL. */ -- 2.34.1