[Lldb-commits] [lldb] [lldb][Windows] Don't let the inferior inherit the --pipe handle (PR #207024)
Charles Zablit via lldb-commits
lldb-commits at lists.llvm.org
Thu Jul 16 08:15:20 PDT 2026
https://github.com/charles-zablit updated https://github.com/llvm/llvm-project/pull/207024
>From 2756fe8450073e7822bafbb17e9268695817759e Mon Sep 17 00:00:00 2001
From: Charles Zablit <c_zablit at apple.com>
Date: Wed, 1 Jul 2026 17:25:00 +0100
Subject: [PATCH 1/2] [lldb][Windows] Don't let the inferior inherit the --pipe
handle
---
lldb/tools/lldb-server/lldb-gdbserver.cpp | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/lldb/tools/lldb-server/lldb-gdbserver.cpp b/lldb/tools/lldb-server/lldb-gdbserver.cpp
index dc3c45358563d..3ac9931f831c1 100644
--- a/lldb/tools/lldb-server/lldb-gdbserver.cpp
+++ b/lldb/tools/lldb-server/lldb-gdbserver.cpp
@@ -11,7 +11,9 @@
#include <cstdio>
#include <cstring>
-#ifndef _WIN32
+#ifdef _WIN32
+#include "lldb/Host/windows/windows.h"
+#else
#include <csignal>
#include <unistd.h>
#endif
@@ -423,6 +425,11 @@ int main_gdbserver(int argc, char *argv[]) {
return EXIT_FAILURE;
}
unnamed_pipe = (pipe_t)Arg;
+#ifdef _WIN32
+ // Prevent the inferior we later launch from inheriting this pipe's write
+ // handle.
+ ::SetHandleInformation((HANDLE)unnamed_pipe, HANDLE_FLAG_INHERIT, 0);
+#endif
}
if (Args.hasArg(OPT_fd)) {
int64_t fd;
>From fb48e8da896b91ac85da1be8765169ac7fbc7142 Mon Sep 17 00:00:00 2001
From: Charles Zablit <c_zablit at apple.com>
Date: Thu, 16 Jul 2026 16:15:06 +0100
Subject: [PATCH 2/2] fixup! [lldb][Windows] Don't let the inferior inherit the
--pipe handle
---
lldb/tools/lldb-server/lldb-gdbserver.cpp | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/lldb/tools/lldb-server/lldb-gdbserver.cpp b/lldb/tools/lldb-server/lldb-gdbserver.cpp
index 3ac9931f831c1..91e0379f05585 100644
--- a/lldb/tools/lldb-server/lldb-gdbserver.cpp
+++ b/lldb/tools/lldb-server/lldb-gdbserver.cpp
@@ -426,6 +426,11 @@ int main_gdbserver(int argc, char *argv[]) {
}
unnamed_pipe = (pipe_t)Arg;
#ifdef _WIN32
+ if (::GetFileType((HANDLE)unnamed_pipe) != FILE_TYPE_PIPE) {
+ WithColor::error() << "'--pipe' argument is not a pipe handle\n"
+ << HelpText;
+ return EXIT_FAILURE;
+ }
// Prevent the inferior we later launch from inheriting this pipe's write
// handle.
::SetHandleInformation((HANDLE)unnamed_pipe, HANDLE_FLAG_INHERIT, 0);
More information about the lldb-commits
mailing list