bug: redirect stderr on FreeBSD to avoid drawing on UI (#897)
This commit is contained in:
parent
31d2e4a746
commit
a07fa305fb
|
@ -219,6 +219,7 @@ dependencies = [
|
|||
"ctrlc",
|
||||
"dirs",
|
||||
"fern",
|
||||
"filedescriptor",
|
||||
"futures",
|
||||
"futures-timer",
|
||||
"fxhash",
|
||||
|
@ -589,6 +590,17 @@ dependencies = [
|
|||
"log",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "filedescriptor"
|
||||
version = "0.8.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7199d965852c3bac31f779ef99cbb4537f80e952e2d6aa0ffeb30cce00f4f46e"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"thiserror",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "float-cmp"
|
||||
version = "0.9.0"
|
||||
|
|
|
@ -111,6 +111,7 @@ winapi = "0.3.9"
|
|||
[target.'cfg(target_os = "freebsd")'.dependencies]
|
||||
serde_json = { version = "1.0.82" }
|
||||
sysctl = { version = "0.5.2", optional = true }
|
||||
filedescriptor = "0.8.2"
|
||||
|
||||
[dev-dependencies]
|
||||
assert_cmd = "2.0.4"
|
||||
|
|
|
@ -251,14 +251,22 @@ impl DataCollector {
|
|||
if self.widgets_to_harvest.use_temp {
|
||||
self.sys.refresh_components();
|
||||
}
|
||||
if cfg!(target_os = "windows") && self.widgets_to_harvest.use_net {
|
||||
self.sys.refresh_networks();
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
{
|
||||
if self.widgets_to_harvest.use_net {
|
||||
self.sys.refresh_networks();
|
||||
}
|
||||
}
|
||||
if cfg!(target_os = "freebsd") && self.widgets_to_harvest.use_disk {
|
||||
self.sys.refresh_disks();
|
||||
}
|
||||
if cfg!(target_os = "freebsd") && self.widgets_to_harvest.use_mem {
|
||||
self.sys.refresh_memory();
|
||||
|
||||
#[cfg(target_os = "freebsd")]
|
||||
{
|
||||
if self.widgets_to_harvest.use_disk {
|
||||
self.sys.refresh_disks();
|
||||
}
|
||||
if self.widgets_to_harvest.use_mem {
|
||||
self.sys.refresh_memory();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -131,6 +131,16 @@ fn main() -> Result<()> {
|
|||
terminal.clear()?;
|
||||
terminal.hide_cursor()?;
|
||||
|
||||
#[cfg(target_os = "freebsd")]
|
||||
let _stderr_fd = {
|
||||
// A really ugly band-aid to suppress stderr warnings on FreeBSD due to sysinfo.
|
||||
use filedescriptor::{FileDescriptor, StdioDescriptor};
|
||||
use std::fs::OpenOptions;
|
||||
|
||||
let path = OpenOptions::new().write(true).open("/dev/null")?;
|
||||
FileDescriptor::redirect_stdio(&path, StdioDescriptor::Stderr)?
|
||||
};
|
||||
|
||||
// Set panic hook
|
||||
panic::set_hook(Box::new(panic_hook));
|
||||
|
||||
|
|
Loading…
Reference in New Issue