diff --git a/coreutils_core/Cargo.toml b/coreutils_core/Cargo.toml index 198fbb74..c5effb18 100644 --- a/coreutils_core/Cargo.toml +++ b/coreutils_core/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "coreutils_core" -version = "0.1.1" +version = "0.1.2" authors = [ "GrayJack ", "Gab David ", @@ -8,7 +8,7 @@ authors = [ description = "A crate with abstractions to implement UNIX core utilities" readme = "README.md" license = "MPL-2.0-no-copyleft-exception" -repository = "https://github.com/GrayJack/coreutils/coreutils_core" +repository = "https://github.com/GrayJack/coreutils/tree/dev/coreutils_core" documentation = "https://docs.rs/coreutils_core" homepage = "https://crates.io/crates/coreutils_core" keywords = ["unix", "coreutils"] diff --git a/coreutils_core/src/os/utmpx.rs b/coreutils_core/src/os/utmpx.rs index b3976f14..86f62a59 100644 --- a/coreutils_core/src/os/utmpx.rs +++ b/coreutils_core/src/os/utmpx.rs @@ -14,7 +14,7 @@ use std::{ error::Error as StdError, fmt::{self, Display}, io, - path::Path, + path::{Path, PathBuf}, }; #[cfg(not(any( target_os = "linux", @@ -196,6 +196,15 @@ impl Utmpx { pub const fn timeval(&self) -> TimeVal { self.timeval } + + /// Check if the device name of the entry is really active. Works around a quirk of + /// BSD systems where the entry type would be USER_PROCESS after it gets killed. + #[inline] + pub fn is_active(&self) -> bool { + let mut path = PathBuf::from("/dev"); + path.push(&self.line.to_string()); + path.exists() + } /// Get the time where the entry was created (often login time) in a more complete /// structure.