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

None

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

---
 .../source/Host/windows/ProcessLauncherWindows.cpp | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/lldb/source/Host/windows/ProcessLauncherWindows.cpp 
b/lldb/source/Host/windows/ProcessLauncherWindows.cpp
index f5adadaf061bf..5945fa20ff4da 100644
--- a/lldb/source/Host/windows/ProcessLauncherWindows.cpp
+++ b/lldb/source/Host/windows/ProcessLauncherWindows.cpp
@@ -141,14 +141,18 @@ ProcessLauncherWindows::LaunchProcess(const 
ProcessLaunchInfo &launch_info,
     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))
+    flags |= CREATE_NEW_CONSOLE;
+
   if (launch_info.GetFlags().Test(eLaunchFlagDebug))
     flags |= DEBUG_ONLY_THIS_PROCESS;
 
-  if (launch_info.GetFlags().Test(eLaunchFlagDisableSTDIO))
-    flags &= ~CREATE_NEW_CONSOLE;
-
   LPVOID env_block = nullptr;
   ::CreateEnvironmentBuffer(launch_info.GetEnvironment(), environment);
   env_block = environment.data();

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

Reply via email to