From f213f4bcc8b69f4d65da076f17238359e2e70b0e Mon Sep 17 00:00:00 2001 From: feeiyu <158308373+feeiyu@users.noreply.github.com> Date: Fri, 24 Oct 2025 23:49:30 +0800 Subject: [PATCH] Fix duplicate process entries in WSL debug attach list (#40591) Closes #40589 Replaced `System::new_all()` with `System::new_with_specifics` to fetch only essential process information and exclude non-main threads from the process list after fix: image Release Notes: - Fix duplicate process entries in WSL debug attach list --- crates/debugger_ui/src/attach_modal.rs | 9 +++++++-- crates/remote_server/src/headless_project.rs | 13 ++++++++++--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/crates/debugger_ui/src/attach_modal.rs b/crates/debugger_ui/src/attach_modal.rs index daa83f71b1c4148398e12f491caf46b5bf556919..e39a842f63590375898c9870c345574e1932a788 100644 --- a/crates/debugger_ui/src/attach_modal.rs +++ b/crates/debugger_ui/src/attach_modal.rs @@ -9,7 +9,7 @@ use task::ZedDebugConfig; use util::debug_panic; use std::sync::Arc; -use sysinfo::System; +use sysinfo::{ProcessRefreshKind, RefreshKind, System, UpdateKind}; use ui::{Context, Tooltip, prelude::*}; use ui::{ListItem, ListItemSpacing}; use workspace::{ModalView, Workspace}; @@ -362,7 +362,12 @@ fn get_processes_for_project(project: &Entity, cx: &mut App) -> Task = System::new_all() + let refresh_kind = RefreshKind::nothing().with_processes( + ProcessRefreshKind::nothing() + .without_tasks() + .with_cmd(UpdateKind::Always), + ); + let mut processes: Box<[_]> = System::new_with_specifics(refresh_kind) .processes() .values() .map(|process| { diff --git a/crates/remote_server/src/headless_project.rs b/crates/remote_server/src/headless_project.rs index 83000c8bac3b409a0dad07490a5f028e482f0662..f9531df2878985396fa13d687731f828cbb3e71a 100644 --- a/crates/remote_server/src/headless_project.rs +++ b/crates/remote_server/src/headless_project.rs @@ -32,7 +32,7 @@ use std::{ path::{Path, PathBuf}, sync::{Arc, atomic::AtomicUsize}, }; -use sysinfo::System; +use sysinfo::{ProcessRefreshKind, RefreshKind, System, UpdateKind}; use util::{ResultExt, paths::PathStyle, rel_path::RelPath}; use worktree::Worktree; @@ -747,9 +747,16 @@ impl HeadlessProject { _cx: AsyncApp, ) -> Result { let mut processes = Vec::new(); - let system = System::new_all(); + let refresh_kind = RefreshKind::nothing().with_processes( + ProcessRefreshKind::nothing() + .without_tasks() + .with_cmd(UpdateKind::Always), + ); - for (_pid, process) in system.processes() { + for process in System::new_with_specifics(refresh_kind) + .processes() + .values() + { let name = process.name().to_string_lossy().into_owned(); let command = process .cmd()