Re: [PATCH] Unbuffer stdout and stderr on windows

Yao Qi
2013-07-23T06:35:31Z

On 07/22/2013 11:40 PM, Eli Zaretskii wrote:
> This is wrong, stdout should be line-buffered by default.
>

stdout is line-buffered if it can be detected to connect to an
interactive device, otherwise it is fully buffered. Cygwin emulates pty
with pipes, and native win32 apps blindly assume all pipes are
non-interactive.

> Also, this punishes batch mode with stdout redirected to a file: its
> stdout buffering (and perhaps also that of stderr, although that's
> less important) will now always be line-buffered, i.e. less efficient.

Yeah, this patch hurts the performance, but gets the outputs in the
correct order, so that testsuite can be run to get a reasonable test result.

>
> Is it possible to detect the "Cygwin ssh session", whatever that
> means, and only do this then? I don't think it's right to change

Unfortunately, I am unable to find a heuristics to tell "GDB is in
cygwin session". There are some differences on env variables between
cygwin and Windows cmd.exe console, but I am afraid that they are not
reliable.

> behavior of a native w32 GDB just because it misbehaves when mixed

This patch is to change the buffered output to unbuffered, so the
behaviour of GDB is not changed, IMO.

> with Cygwin. Mixing native and Cygwin programs is asking for trouble
> to begin with, so punishing good citizens on behalf of that corner
> case is not TRT, IMO.

We test mingw native gdb in cygwin, because it is easy to set up, so
that mingw32 native gdb can be tested more widely. In the last resort,
we may add an option "--cygwin-tty", which I don't really like.

--
Yao (é½å°§)