diff options
author | Thomas Otto <th1000s@posteo.net> | 2021-12-22 23:07:16 +0100 |
---|---|---|
committer | Dan Davison <dandavison7@gmail.com> | 2022-01-03 17:28:27 -0500 |
commit | 8f2a8ce4964253718087bed008bc13fb161e28c6 (patch) | |
tree | 83ed6ac12f24ee5d3d9f189a8d55cdb8a963d0f7 | |
parent | 50ece4b0cc8dab57a69511fd62013feb892c9c20 (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.lock | 4 | ||||
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | src/utils/process.rs | 7 |
3 files changed, 10 insertions, 3 deletions
@@ -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", @@ -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(), } |