This commit is contained in:
dalance
2022-07-19 16:51:32 +09:00
parent d7601eeaf7
commit 0d9effee55
4 changed files with 46 additions and 21 deletions
Generated
+2 -3
View File
@@ -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",
+8 -2
View File
@@ -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"
+18
View File
@@ -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 {
+18 -16
View File
@@ -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)]