Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend ProcessRefreshKind to allow more specific updates #1139

Merged
merged 7 commits into from
Nov 14, 2023
27 changes: 19 additions & 8 deletions src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1401,6 +1401,12 @@ pub struct ProcessRefreshKind {
cpu: bool,
disk_usage: bool,
user: bool,
memory: bool,
cwd: bool,
root: bool,
environ: bool,
cmd: bool,
exe: bool,
}

impl ProcessRefreshKind {
Expand Down Expand Up @@ -1433,6 +1439,12 @@ impl ProcessRefreshKind {
cpu: true,
disk_usage: true,
user: true,
memory: true,
cwd: true,
root: true,
environ: true,
cmd: true,
exe: true,
}
}

Expand All @@ -1443,14 +1455,13 @@ impl ProcessRefreshKind {
with_disk_usage,
without_disk_usage
);
impl_get_set!(
ProcessRefreshKind,
user,
with_user,
without_user,
r#"This refresh is about `user_id` and `group_id`. Please note that it has an effect mostly
on Windows as other platforms get this information alongside the Process information directly."#,
);
impl_get_set!(ProcessRefreshKind, user, with_user, without_user);
impl_get_set!(ProcessRefreshKind, memory, with_memory, without_memory);
impl_get_set!(ProcessRefreshKind, cwd, with_cwd, without_cwd);
impl_get_set!(ProcessRefreshKind, root, with_root, without_root);
impl_get_set!(ProcessRefreshKind, environ, with_environ, without_environ);
impl_get_set!(ProcessRefreshKind, cmd, with_cmd, without_cmd);
impl_get_set!(ProcessRefreshKind, exe, with_exe, without_exe);
}

/// Used to determine what you want to refresh specifically on the [`Cpu`] type.
Expand Down
15 changes: 0 additions & 15 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -506,21 +506,6 @@ mod test {
);
}

// We ensure that the `Process` cmd information is retrieved as expected.
#[test]
fn check_cmd_line() {
if !IS_SUPPORTED {
return;
}
let mut sys = System::new();
sys.refresh_processes_specifics(ProcessRefreshKind::new());

assert!(sys
.processes()
.iter()
.any(|(_, process)| !process.cmd().is_empty()));
}

#[test]
fn check_cpu_arch() {
let s = System::new();
Expand Down
Loading
Loading