Skip to content

test suite: fflush() before fork()

Uli Schlachter requested to merge psychon/cairo:flush-in-tests into master

Forking a process also duplicates the buffers of FILE*s. Thus, if there is pending data, both the parent and the child process will write things. This is seldom a good idea.

This issue was not noticed so far since by default the test suite already calls fflush() a lot. However, when stdout and stderr are both not a tty (according to isatty(1) and isatty(2)), these flushes are skipped. The result is that the child process repeat the full output from the test suite starting with "Compiled against cairo 1.17.4, running on 1.17.4."

To reproduce this problem run: ./cairo-test-suite 2>&1 | cat

Fix this by flushing all the files that I managed to find before fork().

Thanks to Pekka Paalanen for helping me figure this out. (CC @pq)

Signed-off-by: Uli Schlachter psychon@znc.in

Edit: The build log from !136 (closed) previously shrunk by factor 3.5 due to this change.

Edited by Uli Schlachter

Merge request reports