Skip to content

Commit

Permalink
Merge pull request #1139 from GuillaumeGomez/extend-process-refresh-kind
Browse files Browse the repository at this point in the history
Extend `ProcessRefreshKind` to allow more specific updates
  • Loading branch information
GuillaumeGomez authored Nov 14, 2023
2 parents 04c56cb + 3fc0b9e commit fa1275a
Show file tree
Hide file tree
Showing 9 changed files with 707 additions and 439 deletions.
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

0 comments on commit fa1275a

Please sign in to comment.