From c54528651dbc828abf929ac1a931bd88e3dbaa9d Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Wed, 21 Aug 2019 19:41:18 +1200 Subject: [PATCH 1/2] Fix ps again --- src/commands/ps.rs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/commands/ps.rs b/src/commands/ps.rs index fdb878179..be9efc1bb 100644 --- a/src/commands/ps.rs +++ b/src/commands/ps.rs @@ -2,7 +2,8 @@ use crate::commands::WholeStreamCommand; use crate::errors::ShellError; use crate::object::process::process_dict; use crate::prelude::*; -use sysinfo::SystemExt; +#[allow(unused)] +use sysinfo::{RefreshKind, SystemExt}; pub struct PS; @@ -25,7 +26,20 @@ impl WholeStreamCommand for PS { } fn ps(args: CommandArgs, _registry: &CommandRegistry) -> Result { - let system = sysinfo::System::new(); + let system; + + #[cfg(not(windows))] + { + system = sysinfo::System::new(); + } + + #[cfg(windows)] + { + let mut sy = sysinfo::System::new_with_specifics(RefreshKind::new().with_processes()); + sy.refresh_processes(); + + system = sy; + } let list = system.get_process_list(); let list = list From c98bf6834116fc46b0ea4809521081a835d9c564 Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Wed, 21 Aug 2019 19:47:33 +1200 Subject: [PATCH 2/2] Oops, one more time --- src/commands/ps.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/commands/ps.rs b/src/commands/ps.rs index be9efc1bb..970a67844 100644 --- a/src/commands/ps.rs +++ b/src/commands/ps.rs @@ -28,12 +28,12 @@ impl WholeStreamCommand for PS { fn ps(args: CommandArgs, _registry: &CommandRegistry) -> Result { let system; - #[cfg(not(windows))] + #[cfg(linux)] { system = sysinfo::System::new(); } - #[cfg(windows)] + #[cfg(not(linux))] { let mut sy = sysinfo::System::new_with_specifics(RefreshKind::new().with_processes()); sy.refresh_processes();