Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

windows: get pid with win32 api (#8785)

Ezekiel Warren36d9b3d48364
diff --git a/Cargo.lock b/Cargo.lock
index 34c59338446..5e1eff04a84 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -9463,6 +9463,7 @@ dependencies = [
"theme",
"thiserror",
"util",
+ "windows 0.53.0",
]
[[package]]
diff --git a/crates/terminal/Cargo.toml b/crates/terminal/Cargo.toml
index 71232649482..c41168d639f 100644
--- a/crates/terminal/Cargo.toml
+++ b/crates/terminal/Cargo.toml
@@ -30,5 +30,11 @@ theme.workspace = true
thiserror.workspace = true
util.workspace = true
+[target.'cfg(windows)'.dependencies.windows]
+version = "0.53.0"
+features = [
+ "Win32_System_Threading",
+]
+
[dev-dependencies]
rand.workspace = true
diff --git a/crates/terminal/src/terminal.rs b/crates/terminal/src/terminal.rs
index 2ae53d40d22..342d4c6cc20 100644
--- a/crates/terminal/src/terminal.rs
+++ b/crates/terminal/src/terminal.rs
@@ -670,7 +670,7 @@ impl Terminal {
let mut pid = unsafe { libc::tcgetpgrp(self.shell_fd as i32) };
// todo("windows")
#[cfg(windows)]
- let mut pid = -1;
+ let mut pid = unsafe { windows::Win32::System::Threading::GetCurrentProcessId() } as i32;
if pid < 0 {
pid = self.shell_pid as i32;
}