about summary refs log tree commit diff
path: root/library/std/src/sys
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2024-01-22 22:12:06 +0100
committerGitHub <noreply@github.com>2024-01-22 22:12:06 +0100
commit67d093682ce1b63f34b0038068819bd46aadf048 (patch)
tree91190c9bc75eff7bb5e96c47c6f9cca111351172 /library/std/src/sys
parentd5fd0997291ca0135401a39dff25c8a9c13b8961 (diff)
parente74c667a53c6368579867a74494e6fb7a7f17d13 (diff)
Rollup merge of #119664 - ChrisDenton:mingw-pty, r=thomcc
Fix tty detection for msys2's `/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 redirection to  `/dev/ptmx` in an msys2 shell. Maybe this is an msys2 bug but in any case we should try to make it work.

An alternative to this would be to replace the "true negative" detection with an attempt to detect if we're in an msys environment (e.g. by sniffing environment variables) but that seems like it'd be flaky too.

Fixes #119658
Diffstat (limited to 'library/std/src/sys')
-rw-r--r--library/std/src/sys/pal/windows/io.rs14
1 files changed, 0 insertions, 14 deletions
diff --git a/library/std/src/sys/pal/windows/io.rs b/library/std/src/sys/pal/windows/io.rs
index 649826d25ce..b73d9f3ff4c 100644
--- a/library/std/src/sys/pal/windows/io.rs
+++ b/library/std/src/sys/pal/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)
 }