[Lldb-commits] [lldb] [lldb][Windows] Honor the last stdio file action when launching a process (PR #229435)

Charles Zablit via lldb-commits lldb-commits at lists.llvm.org
Wed Oct 7 02:41:15 PDT 2026


https://github.com/charles-zablit updated https://github.com/llvm/llvm-project/pull/229435

>From 95b556ac51150e87935b99df14d135c758769c26 Mon Sep 17 00:00:00 2001
From: Charles Zablit <c_zablit at apple.com>
Date: Tue, 6 Oct 2026 15:16:24 +0100
Subject: [PATCH] [lldb][Windows] Honor the last stdio file action when
 launching a process

---
 .../source/Host/windows/ProcessLauncherWindows.cpp |  8 +++++++-
 .../Shell/Process/Windows/lldb_server_stdio.cpp    | 14 ++++++++++++++
 2 files changed, 21 insertions(+), 1 deletion(-)
 create mode 100644 lldb/test/Shell/Process/Windows/lldb_server_stdio.cpp

diff --git a/lldb/source/Host/windows/ProcessLauncherWindows.cpp b/lldb/source/Host/windows/ProcessLauncherWindows.cpp
index c0583f54bb3168..cd09ff86a1946f 100644
--- a/lldb/source/Host/windows/ProcessLauncherWindows.cpp
+++ b/lldb/source/Host/windows/ProcessLauncherWindows.cpp
@@ -336,7 +336,13 @@ llvm::ErrorOr<std::vector<HANDLE>> ProcessLauncherWindows::GetInheritedHandles(
 HANDLE
 ProcessLauncherWindows::GetStdioHandle(const ProcessLaunchInfo &launch_info,
                                        int fd) {
-  const FileAction *action = launch_info.GetFileActionForFD(fd);
+  const FileAction *action = nullptr;
+  for (size_t i = 0; i < launch_info.GetNumFileActions(); ++i) {
+    const FileAction *candidate = launch_info.GetFileActionAtIndex(i);
+    if (candidate->GetFD() == fd &&
+        candidate->GetAction() != FileAction::eFileActionDuplicate)
+      action = candidate;
+  }
   if (action == nullptr)
     return nullptr;
   const std::string path = action->GetFileSpec().GetPath();
diff --git a/lldb/test/Shell/Process/Windows/lldb_server_stdio.cpp b/lldb/test/Shell/Process/Windows/lldb_server_stdio.cpp
new file mode 100644
index 00000000000000..1046ddf2da169f
--- /dev/null
+++ b/lldb/test/Shell/Process/Windows/lldb_server_stdio.cpp
@@ -0,0 +1,14 @@
+// clang-format off
+
+// lldb-server's stdio is the null device, so nothing it prints ends up in
+// lldb's output.
+
+// REQUIRES: target-windows
+// RUN: %build -o %t.exe -- %s
+// RUN: env LLDB_USE_LLDB_SERVER=1 %lldb -b -o run -f %t.exe 2>&1 | \
+// RUN:   FileCheck %s --implicit-check-not="Connection established" \
+// RUN:     --implicit-check-not="lldb-server exiting"
+
+// CHECK: Process {{[0-9]+}} exited with status = 0
+
+int main() { return 0; }



More information about the lldb-commits mailing list