Skip to content

Commit a4d92d5

Browse files
dschogitster
authored andcommitted
mingw: make stderr unbuffered again
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]> Tested-by: Johannes Sixt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1d3f065 commit a4d92d5

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

compat/winansi.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,8 @@ static HANDLE swap_osfhnd(int fd, HANDLE new_handle)
510510
*/
511511
close(new_fd);
512512

513+
if (fd == 2)
514+
setvbuf(stderr, NULL, _IONBF, BUFSIZ);
513515
fd_is_interactive[fd] |= FD_SWAPPED;
514516

515517
return duplicate;
@@ -547,6 +549,8 @@ static void detect_msys_tty(int fd)
547549
!wcsstr(name, L"-pty"))
548550
return;
549551

552+
if (fd == 2)
553+
setvbuf(stderr, NULL, _IONBF, BUFSIZ);
550554
fd_is_interactive[fd] |= FD_MSYS;
551555
}
552556

0 commit comments

Comments
 (0)