Skip to content

Commit

Permalink
mingw: make stderr unbuffered again
Browse files Browse the repository at this point in the history
When removing the hack for isatty(), we actually removed more than just
an isatty() hack: we removed the hack where internal data structures of
the MSVC runtime are modified in order to redirect stdout/stderr.

Instead of using that hack (that does not work with newer versions of
the runtime, anyway), we replaced it by reopening the respective file
descriptors.

What we forgot was to mark stderr as unbuffered again.

Reported by Hannes Sixt. Fixed with Jeff Hostetler's assistance.

Signed-off-by: Johannes Schindelin <[email protected]>
  • Loading branch information
dscho committed Feb 13, 2017
1 parent df69448 commit 87ad093
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions compat/winansi.c
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,8 @@ static HANDLE swap_osfhnd(int fd, HANDLE new_handle)
*/
close(new_fd);

if (fd == 2)
setvbuf(stderr, NULL, _IONBF, BUFSIZ);
fd_is_interactive[fd] |= FD_SWAPPED;

return duplicate;
Expand Down Expand Up @@ -555,6 +557,8 @@ static void detect_msys_tty(int fd)
!wcsstr(name, L"-pty"))
return;

if (fd == 2)
setvbuf(stderr, NULL, _IONBF, BUFSIZ);
fd_is_interactive[fd] |= FD_MSYS;
}

Expand Down

0 comments on commit 87ad093

Please sign in to comment.