Fix duplicate process entries in WSL debug attach list (#40591)
feeiyu
created 1 week ago
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
Change summary
crates/debugger_ui/src/attach_modal.rs | 9 +++++++--
crates/remote_server/src/headless_project.rs | 13 ++++++++++---
2 files changed, 17 insertions(+), 5 deletions(-)
Detailed changes
@@ -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| {
@@ -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()