[Lldb-commits] [lldb] [lldb][Windows] Fixed Host::Kill() (PR #99721)
Dmitry Vasilyev via lldb-commits
lldb-commits at lists.llvm.org
Fri Jul 19 16:51:30 PDT 2024
https://github.com/slydiman created https://github.com/llvm/llvm-project/pull/99721
HostProcessWindows::Terminate() correctly uses m_process which type is process_t (HANDLE) to call ::TerminateProcess(). But Host::Kill() uses a cast from pid, which is wrong.
>From 0712380a0ef60fae0a3035ac1e572bf9b1ea3bae Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev <dvassiliev at accesssoftek.com>
Date: Sat, 20 Jul 2024 03:48:12 +0400
Subject: [PATCH] [lldb][Windows] Fixed Host::Kill()
HostProcessWindows::Terminate() correctly uses m_process which type is process_t (HANDLE) to call ::TerminateProcess().
But Host::Kill() uses a cast from pid, which is wrong.
---
lldb/source/Host/windows/Host.cpp | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/lldb/source/Host/windows/Host.cpp b/lldb/source/Host/windows/Host.cpp
index 6908f0003eaf7..642092f61d924 100644
--- a/lldb/source/Host/windows/Host.cpp
+++ b/lldb/source/Host/windows/Host.cpp
@@ -103,7 +103,9 @@ lldb::thread_t Host::GetCurrentThread() {
}
void Host::Kill(lldb::pid_t pid, int signo) {
- TerminateProcess((HANDLE)pid, 1);
+ AutoHandle handle(::OpenProcess(PROCESS_TERMINATE, FALSE, pid), nullptr);
+ if (handle.IsValid())
+ ::TerminateProcess(handle.get(), 1);
}
const char *Host::GetSignalAsCString(int signo) { return NULL; }
More information about the lldb-commits
mailing list