diff --git a/src/common.rs b/src/common.rs index 23b1a9805..f0599572f 100644 --- a/src/common.rs +++ b/src/common.rs @@ -234,11 +234,24 @@ impl System { /// Gets all processes and updates their information. /// - /// It does the same as `system.refresh_processes_specifics(ProcessRefreshKind::everything())`. + /// It does the same as: + /// + /// ```no_run + /// # use sysinfo::{ProcessRefreshKind, System}; + /// # let mut system = System::new(); + /// system.refresh_processes_specifics( + /// ProcessRefreshKind::new() + /// .with_memory() + /// .with_cpu() + /// .with_disk_usage(), + /// ); + /// ``` /// /// ⚠️ On Linux, `sysinfo` keeps the `stat` files open by default. You can change this behaviour /// by using [`set_open_files_limit`][crate::set_open_files_limit]. /// + /// Example: + /// /// ```no_run /// use sysinfo::System; /// @@ -246,7 +259,12 @@ impl System { /// s.refresh_processes(); /// ``` pub fn refresh_processes(&mut self) { - self.refresh_processes_specifics(ProcessRefreshKind::everything()); + self.refresh_processes_specifics( + ProcessRefreshKind::new() + .with_memory() + .with_cpu() + .with_disk_usage(), + ); } /// Gets all processes and updates the specified information. @@ -268,8 +286,24 @@ impl System { /// exist (it will **NOT** be removed from the processes if it doesn't exist anymore). If it /// isn't listed yet, it'll be added. /// - /// It is the same as calling - /// `sys.refresh_process_specifics(pid, ProcessRefreshKind::everything())`. + /// It is the same as calling: + /// + /// ```no_run + /// # use sysinfo::{ProcessRefreshKind, System}; + /// # let mut system = System::new(); + /// system.refresh_process_specifics( + /// pid, + /// ProcessRefreshKind::new() + /// .with_memory() + /// .with_cpu() + /// .with_disk_usage(), + /// ); + /// ``` + /// + /// ⚠️ On Linux, `sysinfo` keeps the `stat` files open by default. You can change this behaviour + /// by using [`set_open_files_limit`][crate::set_open_files_limit]. + /// + /// Example: /// /// ```no_run /// use sysinfo::{Pid, System}; @@ -278,13 +312,22 @@ impl System { /// s.refresh_process(Pid::from(1337)); /// ``` pub fn refresh_process(&mut self, pid: Pid) -> bool { - self.refresh_process_specifics(pid, ProcessRefreshKind::everything()) + self.refresh_process_specifics( + pid, + ProcessRefreshKind::new() + .with_memory() + .with_cpu() + .with_disk_usage(), + ) } /// Refreshes *only* the process corresponding to `pid`. Returns `false` if the process doesn't /// exist (it will **NOT** be removed from the processes if it doesn't exist anymore). If it /// isn't listed yet, it'll be added. /// + /// ⚠️ On Linux, `sysinfo` keeps the `stat` files open by default. You can change this behaviour + /// by using [`set_open_files_limit`][crate::set_open_files_limit]. + /// /// ```no_run /// use sysinfo::{Pid, ProcessRefreshKind, System}; ///