summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Otto <th1000s@posteo.net>2021-12-22 23:07:16 +0100
committerDan Davison <dandavison7@gmail.com>2022-01-03 17:28:27 -0500
commit8f2a8ce4964253718087bed008bc13fb161e28c6 (patch)
tree83ed6ac12f24ee5d3d9f189a8d55cdb8a963d0f7
parent50ece4b0cc8dab57a69511fd62013feb892c9c20 (diff)
Disable /proc fd caching on Linux when querying processes
This query only happens once, so caching is not needed Also update sysinfo version to fix a crash related to this.
-rw-r--r--Cargo.lock4
-rw-r--r--Cargo.toml2
-rw-r--r--src/utils/process.rs7
3 files changed, 10 insertions, 3 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 51135de1..63df7763 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1053,9 +1053,9 @@ dependencies = [
[[package]]
name = "sysinfo"
-version = "0.22.3"
+version = "0.22.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b645b59c59114c25d3d554f781b0a1f1f01545d1d02f271bfb1c897bdfdfdcf3"
+checksum = "ccb37aa4af23791c584202d286ed9420e023e9d27e49d5a76215623f4bcc2502"
dependencies = [
"cfg-if 1.0.0",
"core-foundation-sys",
diff --git a/Cargo.toml b/Cargo.toml
index cdcf455e..6f46bcf1 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -53,7 +53,7 @@ default-features = false
features = ["parsing", "assets", "yaml-load", "dump-load", "regex-onig"]
[dependencies.sysinfo]
-version = "0.22.3"
+version = "0.22.4"
# no default features to disable the use of threads
default-features = false
features = []
diff --git a/src/utils/process.rs b/src/utils/process.rs
index 68b57a6a..eac564e0 100644
--- a/src/utils/process.rs
+++ b/src/utils/process.rs
@@ -226,6 +226,13 @@ struct ProcInfo {
}
impl ProcInfo {
fn new() -> Self {
+ // On Linux sysinfo optimizes for repeated process queries and keeps per-process
+ // /proc file descriptors open. This caching is not needed here, so
+ // set this to zero (this does nothing on other platforms).
+ // Also, there is currently a kernel bug which slows down syscalls when threads are
+ // involved (here: the ctrlc handler) and a lot of files are kept open.
+ sysinfo::set_open_files_limit(0);
+
ProcInfo {
info: sysinfo::System::new(),
}