use super::codes;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(crate) enum OwnerPidfdFailure {
CoscaGone,
Unwatchable,
}
impl OwnerPidfdFailure {
pub(crate) fn from_errno(errno: i32) -> OwnerPidfdFailure {
match errno {
libc::ESRCH | libc::EINVAL => OwnerPidfdFailure::CoscaGone,
_ => OwnerPidfdFailure::Unwatchable,
}
}
pub(crate) fn exit_code(self) -> i32 {
match self {
OwnerPidfdFailure::CoscaGone => codes::OWNER_GONE,
OwnerPidfdFailure::Unwatchable => codes::OWNER_WATCH,
}
}
}
#[cfg(test)]
#[path = "owner_watch_tests.rs"]
mod owner_watch_tests;