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:
<img width="641" height="474" alt="image"
src="https://github.com/user-attachments/assets/32335552-2f7a-4317-8c01-f37b2eadfdc1"
/>


Release Notes:

- Fix duplicate process entries in WSL debug attach list
This commit is contained in:
feeiyu
2025-10-24 11:49:30 -04:00
committed by GitHub
parent 0ee6ca1767
commit f213f4bcc8
2 changed files with 17 additions and 5 deletions
+7 -2
View File
@@ -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<Project>, cx: &mut App) -> Task<Ar
Arc::from(processes.into_boxed_slice())
})
} else {
let mut processes: Box<[_]> = 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| {
+10 -3
View File
@@ -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<proto::GetProcessesResponse> {
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()