Skip to content

Commit e74c667

Browse files
committed
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`.
1 parent 366d112 commit e74c667

File tree

1 file changed

+0
-14
lines changed
  • library/std/src/sys/pal/windows

1 file changed

+0
-14
lines changed

library/std/src/sys/pal/windows/io.rs

-14
Original file line numberDiff line numberDiff line change
@@ -97,20 +97,6 @@ unsafe fn handle_is_console(handle: BorrowedHandle<'_>) -> bool {
9797
return true;
9898
}
9999

100-
// At this point, we *could* have a false negative. We can determine that this is a true
101-
// negative if we can detect the presence of a console on any of the standard I/O streams. If
102-
// another stream has a console, then we know we're in a Windows console and can therefore
103-
// trust the negative.
104-
for std_handle in [c::STD_INPUT_HANDLE, c::STD_OUTPUT_HANDLE, c::STD_ERROR_HANDLE] {
105-
let std_handle = c::GetStdHandle(std_handle);
106-
if !std_handle.is_null()
107-
&& std_handle != handle
108-
&& c::GetConsoleMode(std_handle, &mut out) != 0
109-
{
110-
return false;
111-
}
112-
}
113-
114100
// Otherwise, we fall back to an msys hack to see if we can detect the presence of a pty.
115101
msys_tty_on(handle)
116102
}

0 commit comments

Comments
 (0)