diff --git a/win32/win32.c b/win32/win32.c index 473a6d0c62ca..a480bc8c4b94 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -4000,7 +4000,10 @@ win32_isatty(int fd) return 0; } - if (GetConsoleMode(fh, &mode)) + /* Prevent executing RtlNtStatusToDosError() for disk files and sockets + inside GetConsoleMode(). RtlNtStatusToDosError() does a slow linear + search. For details, see PR for this commit.*/ + if (GetFileType(fh) == FILE_TYPE_CHAR && GetConsoleMode(fh, &mode)) return 1; errno = ENOTTY;