diff --git a/Cargo.lock b/Cargo.lock index 27fa36b..5ea5665 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1453,9 +1453,8 @@ dependencies = [ [[package]] name = "procfs" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57928c5e4262566636d405e7c6a5a4f59bcb61a04a65dea57cf26b0dc3de6423" +version = "0.13.2" +source = "git+https://github.com/dalance/procfs?branch=bsd_support#82f424131f7496735abf8409b13d9486e82e1976" dependencies = [ "bitflags", "byteorder", diff --git a/Cargo.toml b/Cargo.toml index 5687ae2..3e8a887 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -53,9 +53,15 @@ termbg = "0.4.1" toml = "0.5" unicode-width = "0.1" -[target.'cfg(any(target_os = "linux", target_os = "android", target_os = "freebsd", target_os = "openbsd", target_os = "netbsd"))'.dependencies] +[target.'cfg(any(target_os = "linux", target_os = "android"))'.dependencies] pager = "0.16" -procfs = "0.13.0" +#procfs = "0.13.0" +procfs = { git = "https://github.com/dalance/procfs", branch = "bsd_support" } +users = "0.11" +which = "4" + +[target.'cfg(any(target_os = "freebsd", target_os = "openbsd", target_os = "netbsd"))'.dependencies] +procfs = { git = "https://github.com/dalance/procfs", branch = "bsd_support" } users = "0.11" which = "4" diff --git a/src/columns/policy.rs b/src/columns/policy.rs index dc066df..330713e 100644 --- a/src/columns/policy.rs +++ b/src/columns/policy.rs @@ -66,6 +66,24 @@ impl Column for Policy { column_default!(String); } +#[cfg(any(target_os = "freebsd", target_os = "openbsd", target_os = "netbsd"))] +impl Column for Policy { + fn add(&mut self, proc: &ProcessInfo) { + let fmt_content = match proc.curr_proc.stat().policy.map(|x| x as i32) { + Some(libc::SCHED_FIFO) => String::from("FF"), + Some(libc::SCHED_OTHER) => String::from("TS"), + Some(libc::SCHED_RR) => String::from("RR"), + _ => String::from(""), + }; + let raw_content = fmt_content.clone(); + + self.fmt_contents.insert(proc.pid, fmt_content); + self.raw_contents.insert(proc.pid, raw_content); + } + + column_default!(String); +} + #[cfg_attr(tarpaulin, skip)] #[cfg(target_os = "macos")] impl Column for Policy { diff --git a/src/view.rs b/src/view.rs index 92fa10d..323a701 100644 --- a/src/view.rs +++ b/src/view.rs @@ -10,7 +10,12 @@ use crate::util::{ }; use crate::Opt; use anyhow::{bail, Error}; -#[cfg(not(target_os = "windows"))] +#[cfg(not(any( + target_os = "windows", + target_os = "freebsd", + target_os = "openbsd", + target_os = "netbsd" +)))] use pager::Pager; use std::collections::HashMap; use std::time::Duration; @@ -583,13 +588,11 @@ impl View { #[cfg(not(any( target_os = "windows", - any( - target_os = "linux", - target_os = "android", - target_os = "freebsd", - target_os = "openbsd", - target_os = "netbsd" - ) + target_os = "linux", + target_os = "android", + target_os = "freebsd", + target_os = "openbsd", + target_os = "netbsd" )))] fn pager(config: &Config) { if let Some(ref pager) = config.pager.command { @@ -601,13 +604,7 @@ impl View { } } - #[cfg(any( - target_os = "linux", - target_os = "android", - target_os = "freebsd", - target_os = "openbsd", - target_os = "netbsd" - ))] + #[cfg(any(target_os = "linux", target_os = "android"))] fn pager(config: &Config) { if let Some(ref pager) = config.pager.command { Pager::with_pager(pager) @@ -623,7 +620,12 @@ impl View { } } - #[cfg(target_os = "windows")] + #[cfg(any( + target_os = "windows", + target_os = "freebsd", + target_os = "openbsd", + target_os = "netbsd" + ))] fn pager(_config: &Config) {} #[cfg_attr(tarpaulin, skip)]