https://github.com/charles-zablit created 
https://github.com/llvm/llvm-project/pull/177934

This patch ensures lldb will not try to read from a PseudoConsole if it has not 
been opened.

This patch fixes https://github.com/llvm/llvm-project/issues/175652.

>From c3ec9d7ff698816f363ca7cdb95b5044540680a8 Mon Sep 17 00:00:00 2001
From: Charles Zablit <[email protected]>
Date: Mon, 26 Jan 2026 12:00:27 +0000
Subject: [PATCH] [lldb][windows] do not attach to a PseudoConsole if it is not
 opened

---
 .../Plugins/Platform/Windows/PlatformWindows.cpp       | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp 
b/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
index 7d5a5a503474c..77552f1073879 100644
--- a/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
+++ b/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
@@ -522,9 +522,13 @@ ProcessSP PlatformWindows::DebugProcess(ProcessLaunchInfo 
&launch_info,
     return nullptr;
   error = process_sp->Launch(launch_info);
 #ifdef _WIN32
-  if (error.Success())
-    process_sp->SetPseudoConsoleHandle(launch_info.GetPTYSP());
-  else {
+  if (error.Success()) {
+    if (launch_info.GetPTY().GetPseudoTerminalHandle() !=
+            INVALID_HANDLE_VALUE &&
+        launch_info.GetNumFileActions() == 0 &&
+        launch_info.GetFlags().Test(lldb::eLaunchFlagLaunchInTTY))
+      process_sp->SetPseudoConsoleHandle(launch_info.GetPTYSP());
+  } else {
     Log *log = GetLog(LLDBLog::Platform);
     LLDB_LOGF(log, "Platform::%s LaunchProcess() failed: %s", __FUNCTION__,
               error.AsCString());

_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to