]> git.ipfire.org Git - thirdparty/util-linux.git/commit
lib/pager: fix output truncation from buffered stdout
authorChris Webb <chris@arachsys.com>
Tue, 9 May 2023 16:46:00 +0000 (17:46 +0100)
committerChris Webb <chris@arachsys.com>
Tue, 9 May 2023 16:46:00 +0000 (17:46 +0100)
commit45e7e8883a7a85713c1528db858b760f4d0d50e0
tree8032e2f9da6574fee7d0f9d535869aa4ddce40fb
parent10d477ac7849eee1ce6ac82b73d6f02ff6db701c
lib/pager: fix output truncation from buffered stdout

Commit 518a0ad dropped fflush(stdout) and fflush(stderr) from
wait_for_pager() before STDOUT_FILENO and STDERR_FILENO are closed
because it is called from a signal handler and they are async-unsafe.

However, failure to flush output leads to unwanted truncation when
stdout is fully buffered, which it is by default when we are linked
against musl.

Ensure stdout and stderr are line-buffered before redirecting them to
the pager subprocess to avoid this.

Addresses: https://github.com/util-linux/util-linux/issues/2218
Signed-off-by: Chris Webb <chris@arachsys.com>
lib/pager.c