jiixyj/loudness-scanner — pull request #6 by nu774 (2013-12-16 15:14:16+00:00)
Title: set stdout/stderr to be unbuffered when they are not connected to a file

This fixes somewhat jumbled output due to mixed usage of stdout and
stderr without proper calls to fflush() and letting stdio choose the
default buffering strategy.
On win32, pipes are often used instead pty (since there's no pty on win32),
therefore this issue has higher possibility to appear. For example,
running scanner in psuedo terminal application such as mintty is
enough to reproduce the issue.
unbuffered mode is a simple way to ensure output order to be
always preserved, at the expence of tiny I/O overhead that should be
negligible.