Repository: GuillaumeGomez/sysinfo (language: rust)

Issue:
read_bytes always return 0 on nixos and macos
I have a timer reading the values every 5 second, and i then do random read/writes.
On nixos and macos and windows, written_bytes works, but read_bytes is always 0 except on windows.
Am I missing a function call to refresh the information or does read only work on windows ?

**bare bone example, to reproduce**
Cargo.toml
```
sysinfo = "0.29"
```
example code
```
    let pid = get_current_pid()?;
    let sys = System::new_all();
    println!("System name:             {:?}", sys.name());
    println!("System kernel version:   {:?}", sys.kernel_version());
    println!("System OS version:       {:?}", sys.os_version());
    println!("System host name:        {:?}", sys.host_name());
    let sys = Arc::new(Mutex::new(sys));
    std::thread::spawn(move || {
        loop {
            {
                let mut file = std::fs::File::create("testfile.txt").unwrap();
                let _ = file.write_all("Hello world".as_bytes());
                file.sync_all().unwrap();
            }
            {
                let mut file = std::fs::File::open("testfile.txt").unwrap();
                let mut contents = String::new();
                file.read_to_string(&mut contents).unwrap();
            }

            std::thread::sleep(std::time::Duration::from_secs(5));
            let mut sys = sys.lock().unwrap();
            sys.refresh_process(pid);
            if let Some(process) = sys.process(pid) {
                let disk_io = process.disk_usage();
                println!("read: {:?} write: {:?} total read: {:?} total write: {:?}", disk_io.read_bytes, disk_io.written_bytes, disk_io.total_read_bytes, disk_io.total_written_bytes);
            }
        }
    });
```
Output on nixos
```
System name:             Some("NixOS")
System kernel version:   Some("6.1.96")
System OS version:       Some("23.11")
System host name:        Some("nixos")
read: 0 write: 0 total read: 0 total write: 4096
read: 0 write: 0 total read: 0 total write: 8192
read: 0 write: 0 total read: 0 total write: 12288
read: 0 write: 0 total read: 0 total write: 16384
read: 0 write: 0 total read: 0 total write: 20480
read: 0 write: 0 total read: 0 total write: 24576
```
Output on macos
```
System name:             Some("Darwin")
System kernel version:   Some("23.1.0")
System OS version:       Some("14.1.2")
System host name:        Some("Allans-Mac-mini.local")
read: 417792 write: 61440 total read: 417792 total write: 61440
read: 0 write: 4096 total read: 417792 total write: 65536
read: 0 write: 4096 total read: 417792 total write: 69632
read: 0 write: 4096 total read: 417792 total write: 73728
read: 0 write: 4096 total read: 417792 total write: 77824
read: 0 write: 4096 total read: 417792 total write: 81920
```
Output on windows 10
```
System name:             Some("Windows")
System kernel version:   Some("19045")
System OS version:       Some("10 (19045)")
System host name:        Some("mac-windows")
read: 11 write: 11 total read: 1090997 total write: 11
read: 11 write: 11 total read: 1091008 total write: 22
read: 11 write: 11 total read: 1091019 total write: 33
read: 11 write: 11 total read: 1091030 total write: 44
read: 11 write: 11 total read: 1091041 total write: 55
read: 11 write: 11 total read: 1091052 total write: 66
read: 11 write: 11 total read: 1091063 total write: 77
```



Discussion / hints:
On macOS, I confirmed that `read` doesn't change all the time. However, interestingly enough, `Activity Monitor` gives the same read value. So I suppose it's a mac bug or mac is not reading file content if it's the same.

Fix patch:
diff --git a/src/common/system.rs b/src/common/system.rs
index 5fb82956f..1409becd1 100644
--- a/src/common/system.rs
+++ b/src/common/system.rs
@@ -942,6 +942,10 @@ pub struct CGroupLimits {
 ///
 /// It is returned by [`Process::disk_usage`][crate::Process::disk_usage].
 ///
+/// ⚠️ Files might be cached in memory by your OS, meaning that reading/writing them might not
+/// increase the `read_bytes`/`written_bytes` values. You can find more information about it
+/// in the `proc_pid_io` manual (`man proc_pid_io` on unix platforms).
+///
 /// ```no_run
 /// use sysinfo::System;
 ///
@@ -1440,6 +1444,10 @@ impl Process {
     /// ⚠️ On Windows, this method actually returns **ALL** I/O read and
     /// written bytes.
     ///
+    /// ⚠️ Files might be cached in memory by your OS, meaning that reading/writing them might not
+    /// increase the `read_bytes`/`written_bytes` values. You can find more information about it
+    /// in the `proc_pid_io` manual (`man proc_pid_io` on unix platforms).
+    ///
     /// ```no_run
     /// use sysinfo::{Pid, System};
     ///


Test patch: