Skip to content

Commit 9a033b8

Browse files
committed
win32_isatty() dont call a mostly failing syscall, NT->WIN err conv is slow
1 parent 8c71d4a commit 9a033b8

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

win32/win32.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4000,7 +4000,10 @@ win32_isatty(int fd)
40004000
return 0;
40014001
}
40024002

4003-
if (GetConsoleMode(fh, &mode))
4003+
/* Prevent executing RtlNtStatusToDosError() for disk files and sockets
4004+
inside GetConsoleMode(). RtlNtStatusToDosError() does a slow linear
4005+
search. For details, see PR for this commit.*/
4006+
if (GetFileType(fh) == FILE_TYPE_CHAR && GetConsoleMode(fh, &mode))
40044007
return 1;
40054008

40064009
errno = ENOTTY;

0 commit comments

Comments
 (0)