Re: [PATCH] Unbuffer stdout and stderr on windows

Pedro Alves
2013-08-16T15:24:05Z

On 08/16/2013 04:10 PM, Pedro Alves wrote:

>> A complete solution, if it exists, might require much more effort,
>
> I don't think it does.
>
> - First, make stderr always unbuffered. That's what you get on
> most platforms anyway.
> - Then, somewhere along fputs_unfiltered or some central output routine,
> keep track of which was the last to be used between stdout and stderr.
> If outputting to stderr, flush stdout first. Don't need to do the
> opposite, since stderr will always be unbuffered.

Or alternatively, like Tromey suggested, make fputs_unfiltered
or some such implement line buffering internally (for Windows hosts),
either by just forcing flushes at endlines (partial emulation), or
with real local buffering. That potentially gets us a behavior
on Windows/pipes even closer to other platforms. (His suggestion
was kind of sidetracked by the \n -> \r\n bit, but that's actually
a separate issue).

(Neither solution looks that complicated to me.)

--
Pedro Alves