diff --git a/procfs/src/net.rs b/procfs/src/net.rs index e297687..177ff9e 100644 --- a/procfs/src/net.rs +++ b/procfs/src/net.rs @@ -23,7 +23,10 @@ //! // build up a map between socket inodes and process stat info: //! let mut map: HashMap = HashMap::new(); //! for p in all_procs { -//! let process = p.unwrap(); +//! let Ok(process) = p else { +//! // process vanished +//! continue; +//! }; //! if let (Ok(stat), Ok(fds)) = (process.stat(), process.fd()) { //! for fd in fds { //! if let FDTarget::Socket(inode) = fd.unwrap().target { diff --git a/procfs/src/process/mod.rs b/procfs/src/process/mod.rs index d05ddf7..201198e 100644 --- a/procfs/src/process/mod.rs +++ b/procfs/src/process/mod.rs @@ -25,7 +25,15 @@ //! //! let tty = format!("pty/{}", me_stat.tty_nr().1); //! for prc in procfs::process::all_processes().unwrap() { -//! if let Ok(stat) = prc.unwrap().stat() { +//! let Ok(prc) = prc else { +//! // process vanished +//! continue; +//! }; +//! let Ok(stat) = prc.stat() else { +//! // process vanished +//! continue; +//! }; +//! if let Ok(stat) = prc.stat() { //! if stat.tty_nr == me_stat.tty_nr { //! // total_time is in seconds //! let total_time =