From d72993e66258f4956c236dc7da9f6c26e11dbfcc Mon Sep 17 00:00:00 2001 From: Chris Denton Date: Sat, 6 Jan 2024 16:07:27 +0000 Subject: [PATCH] Fix msys2 tty detection for /dev/ptmx Our "true negative" detection assumes that if at least one std handle is a Windows console then no other handle will be a msys2 tty pipe. This turns out to be a faulty assumption in the case of `/dev/ptmx`. --- library/std/src/sys/windows/io.rs | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/library/std/src/sys/windows/io.rs b/library/std/src/sys/windows/io.rs index 649826d25cef7..b73d9f3ff4c4a 100644 --- a/library/std/src/sys/windows/io.rs +++ b/library/std/src/sys/windows/io.rs @@ -97,20 +97,6 @@ unsafe fn handle_is_console(handle: BorrowedHandle<'_>) -> bool { return true; } - // At this point, we *could* have a false negative. We can determine that this is a true - // negative if we can detect the presence of a console on any of the standard I/O streams. If - // another stream has a console, then we know we're in a Windows console and can therefore - // trust the negative. - for std_handle in [c::STD_INPUT_HANDLE, c::STD_OUTPUT_HANDLE, c::STD_ERROR_HANDLE] { - let std_handle = c::GetStdHandle(std_handle); - if !std_handle.is_null() - && std_handle != handle - && c::GetConsoleMode(std_handle, &mut out) != 0 - { - return false; - } - } - // Otherwise, we fall back to an msys hack to see if we can detect the presence of a pty. msys_tty_on(handle) }