Skip to contentSkip to conversation

"findmnt --poll" does not flush stdout causing it to buffer the output more than it should when the output is to a pipe or file.

PROBLEM Pedro Miguel Carvalho 2 participants 2 messages Jan 20, 2017 – Jan 31, 2017 Util-Linux package

lore
Share & tools
lore
#0 lore raw

"findmnt --poll" does not flush stdout causing it to buffer the output more than it should when the output is to a pipe or file.

This issue can be observed by comparing the output of:

	findmnt --poll --pairs
with the output of:
	findmnt --poll --pairs | tee /tmp/output.log

when these two command are run at the same time
and some filesystems are (un)(re)mounted.

Redirecting the output to a file:

	findmnt --poll --pairs > /tmp/output.log
or executing findmnt with ssh:
	ssh user@server findmnt --poll --pairs

also show the same symptom.

The attached patch simply adds a "fflush(stdout);" after the output is printed.

Thanks

p.s. I'm not certain if this is the proper place and way to report this issue. If this should go somewhere else, please point me in the right direction.

misc-utils/findmnt.c +1 -0
index aff2847..3984d44 100644
@@ -1142,6 +1142,7 @@ static int poll_table(struct libmnt_table *tb, const char *tabfile,
 
 		if (count) {
 			rc = scols_table_print_range(table, NULL, NULL);
+			fflush(stdout);
 			if (rc)
 				goto done;
 		}
maintainer
#1 lore raw
Quoted 2 lines · Pedro Miguel Carvalho

"findmnt --poll" does not flush stdout causing it to buffer the output more than it should when the output is to a pipe or file.

Fixed. Thanks!

Karel

Signature · 2 lines
 Karel Zak  <[email protected]>
 http://karelzak.blogspot.com