From 6a7fd37d344bcec433fdfbcc25d861db01ea4d9b Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Sat, 1 Jan 2022 09:53:56 -0700 Subject: [PATCH] procinfo: add some comments --- procinfo/src/lib.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/procinfo/src/lib.rs b/procinfo/src/lib.rs index 7da56f213..21798fdd6 100644 --- a/procinfo/src/lib.rs +++ b/procinfo/src/lib.rs @@ -24,21 +24,43 @@ pub enum LocalProcessStatus { #[derive(Debug, Serialize, Deserialize, Clone)] pub struct LocalProcessInfo { + /// The process identifier pub pid: u32, + /// The parent process identifier pub ppid: u32, + /// The COMM name of the process. May not bear any relation to + /// the executable image name. May be changed at runtime by + /// the process. + /// Many systems truncate this + /// field to 15-16 characters. pub name: String, + /// Path to the executable image pub executable: PathBuf, + /// The argument vector. + /// Some systems allow changing the argv block at runtime + /// eg: setproctitle(). pub argv: Vec, + /// The current working directory for the process, or an empty + /// path if it was not accessible for some reason. pub cwd: PathBuf, + /// The status of the process. Not all possible values are + /// portably supported on all systems. pub status: LocalProcessStatus, + /// A clock value in unspecified system dependent units that + /// indicates the relative age of the process. pub start_time: u64, + /// The console handle associated with the process, if any. #[cfg(windows)] pub console: u64, + /// Child processes, keyed by pid pub children: HashMap, } luahelper::impl_lua_conversion!(LocalProcessInfo); impl LocalProcessInfo { + /// Walk this sub-tree of processes and return a unique set + /// of executable base names. eg: `foo/bar` and `woot/bar` + /// produce a set containing just `bar`. pub fn flatten_to_exe_names(&self) -> HashSet { let mut names = HashSet::new();