]> git.ipfire.org Git - thirdparty/dhcpcd.git/commit
dhcpcd: stdout output sometimes empty when redirected to a file (#364)
authorDiego Santa cruz <diego.santacruz@spinetix.com>
Thu, 10 Oct 2024 10:45:34 +0000 (12:45 +0200)
committerGitHub <noreply@github.com>
Thu, 10 Oct 2024 10:45:34 +0000 (11:45 +0100)
commitdc9cbc3e56b1e17f7c1a81a87a42b1f35470c71f
treed063abf03ec1a8a5882f1639ec6b3cfb2704cc46
parentd6c85373600177f5a549211bcdac8fbab7b02731
dhcpcd: stdout output sometimes empty when redirected to a file (#364)

Running dhpcd --dumplease with input from stdin and redirecting stdout
to a file outputs nothing to the output. The reason is that printf /
fprintf is used to write the output but it is not explicitly flushed
when done, or before exiting, and stdout to files is fully buffered by
default while stdout to terminals is line buffered by default.

This adds calls to fflush() at the end of dhcp_print_option_encoding()
and script_dump(), plus one just before exiting dhcpcd.

Signed-off-by: Diego Santa Cruz <diego.santacruz@spinetix.com>
src/dhcp-common.c
src/dhcpcd.c
src/script.c