Skip to content

Commit 87ad093

Browse files
committed
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]>
1 parent df69448 commit 87ad093

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

compat/winansi.c

+4
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,8 @@ static HANDLE swap_osfhnd(int fd, HANDLE new_handle)
505505
*/
506506
close(new_fd);
507507

508+
if (fd == 2)
509+
setvbuf(stderr, NULL, _IONBF, BUFSIZ);
508510
fd_is_interactive[fd] |= FD_SWAPPED;
509511

510512
return duplicate;
@@ -555,6 +557,8 @@ static void detect_msys_tty(int fd)
555557
!wcsstr(name, L"-pty"))
556558
return;
557559

560+
if (fd == 2)
561+
setvbuf(stderr, NULL, _IONBF, BUFSIZ);
558562
fd_is_interactive[fd] |= FD_MSYS;
559563
}
560564

0 commit comments

Comments
 (0)