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

>From f2473b3e14332ebb1668360fb92b75124f6e1346 Mon Sep 17 00:00:00 2001
From: Charles Zablit <[email protected]>
Date: Wed, 6 May 2026 16:05:28 +0100
Subject: [PATCH] [lldb][windows] do not open a new windows when running a
 shell command

---
 .../Host/windows/ProcessLauncherWindows.cpp      | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/lldb/source/Host/windows/ProcessLauncherWindows.cpp 
b/lldb/source/Host/windows/ProcessLauncherWindows.cpp
index 79e0faca64961..3bc2d99611859 100644
--- a/lldb/source/Host/windows/ProcessLauncherWindows.cpp
+++ b/lldb/source/Host/windows/ProcessLauncherWindows.cpp
@@ -198,15 +198,19 @@ ProcessLauncherWindows::LaunchProcess(const 
ProcessLaunchInfo &launch_info,
     startupinfoex.StartupInfo.wShowWindow = SW_HIDE;
   }
 
-  DWORD flags = CREATE_NEW_CONSOLE | CREATE_UNICODE_ENVIRONMENT |
-                EXTENDED_STARTUPINFO_PRESENT;
+  DWORD flags = CREATE_UNICODE_ENVIRONMENT | EXTENDED_STARTUPINFO_PRESENT;
+  const bool stdio_redirected = launch_info.GetFileActionForFD(STDIN_FILENO) &&
+                                launch_info.GetFileActionForFD(STDOUT_FILENO) 
&&
+                                launch_info.GetFileActionForFD(STDERR_FILENO);
+  if (stdio_redirected)
+    flags |= CREATE_NO_WINDOW;
+  else if (!launch_info.GetFlags().Test(eLaunchFlagDisableSTDIO) ||
+           pty_mode == PseudoConsole::Mode::None)
+    flags |= CREATE_NEW_CONSOLE;
+
   if (launch_info.GetFlags().Test(eLaunchFlagDebug))
     flags |= DEBUG_ONLY_THIS_PROCESS;
 
-  if (launch_info.GetFlags().Test(eLaunchFlagDisableSTDIO) ||
-      pty_mode != PseudoConsole::Mode::None)
-    flags &= ~CREATE_NEW_CONSOLE;
-
   std::vector<wchar_t> environment =
       CreateEnvironmentBufferW(launch_info.GetEnvironment());
 

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

Reply via email to