use std::os::fd::{AsFd, AsRawFd, BorrowedFd};
use std::time::Instant;
use crate::identity::RawPid;
pub(crate) const PROC_PIDFDPIPEINFO: libc::c_int = 6;
pub(crate) const PROC_FP_CLEXEC: u32 = 2;
#[repr(C)]
#[derive(Clone, Copy)]
pub(crate) struct ProcFileInfo {
fi_openflags: u32,
fi_status: u32,
fi_offset: i64,
fi_type: i32,
fi_guardflags: u32,
}
#[repr(C)]
#[derive(Clone, Copy)]
pub(crate) struct PipeFdInfo {
pfi: ProcFileInfo,
pipe_stat: libc::vinfo_stat,
pub(crate) pipe_handle: u64,
pub(crate) pipe_peerhandle: u64,
pipe_status: i32,
rfu_1: i32,
}
const _: () = assert!(std::mem::size_of::<ProcFileInfo>() == 24);
const _: () = assert!(std::mem::size_of::<PipeFdInfo>() == 184);
const _: () = assert!(std::mem::offset_of!(PipeFdInfo, pipe_handle) == 160);
pub(crate) fn pipe_handle_of(fd: BorrowedFd<'_>) -> Option<u64> {
match fd_pipe_info(std::process::id(), fd.as_raw_fd()) {
FdPipeInfoQuery::Found(info) => Some(info.pipe_handle),
FdPipeInfoQuery::Absent | FdPipeInfoQuery::Denied => None,
}
}
pub(crate) enum FdPipeInfoQuery {
Found(PipeFdInfo),
Absent,
Denied,
}
pub(crate) fn fd_pipe_info(pid: RawPid, fd: libc::c_int) -> FdPipeInfoQuery {
let mut info: PipeFdInfo = unsafe { std::mem::zeroed() };
let size = std::mem::size_of::<PipeFdInfo>() as libc::c_int;
let n = clear_errno_and_call(|| unsafe {
libc::proc_pidfdinfo(
pid as libc::c_int,
fd,
PROC_PIDFDPIPEINFO,
&mut info as *mut _ as *mut libc::c_void,
size,
)
});
if n == size {
return FdPipeInfoQuery::Found(info);
}
match std::io::Error::last_os_error().raw_os_error() {
None | Some(0) | Some(libc::ESRCH) | Some(libc::EBADF) => FdPipeInfoQuery::Absent,
_ => FdPipeInfoQuery::Denied,
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(crate) struct Holder {
pub pid: RawPid,
pub clexec: bool,
}
pub(crate) enum PipeQuery {
Found(Vec<libc::c_int>),
Gone,
Denied,
}
pub(crate) fn holders(handle: u64, pids: &[RawPid]) -> Vec<Holder> {
let mut out = Vec::new();
let mut denied = 0usize;
for &pid in pids {
let fds = match pipe_fds_of(pid) {
PipeQuery::Found(fds) => fds,
PipeQuery::Gone => continue,
PipeQuery::Denied => {
denied += 1;
continue;
}
};
let mut found = false;
let mut all_clexec = true;
for fd in fds {
match fd_pipe_info(pid, fd) {
FdPipeInfoQuery::Found(info) => {
if info.pipe_handle != handle {
continue;
}
found = true;
all_clexec &= info.pfi.fi_status & PROC_FP_CLEXEC != 0;
}
FdPipeInfoQuery::Absent => {
log::debug!(
"fd marker {handle:#x}: PROC_PIDFDPIPEINFO for pid {pid} fd {fd} \
(already listed as a pipe) came back empty; treating as vanished \
between the two calls"
);
}
FdPipeInfoQuery::Denied => {
denied += 1;
log::debug!(
"fd marker {handle:#x}: PROC_PIDFDPIPEINFO for pid {pid} fd {fd} \
(already listed as a pipe) was denied"
);
}
}
}
if !found {
continue;
}
if all_clexec {
log::warn!(
"fd marker {handle:#x}: holder pid {pid} will lose the marker at its next \
exec (every copy of its inherited descriptor is FD_CLOEXEC)"
);
}
out.push(Holder {
pid,
clexec: all_clexec,
});
}
if denied > 0 {
log::debug!(
"fd marker {handle:#x}: {denied} of {} host pids were unqueryable this pass \
(access denied); none were confirmed holders, but a denied pid already holding \
the marker would be invisible to this scan",
pids.len()
);
}
out
}
#[cfg_attr(
not(test),
allow(
dead_code,
reason = "only tests call it; production uses holds_marker_query directly"
)
)]
pub(crate) fn holds_marker(pid: RawPid, handle: u64) -> bool {
matches!(holds_marker_query(pid, handle), MarkerQuery::Held)
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(crate) enum MarkerQuery {
Held,
NotHeld,
Denied,
}
pub(crate) fn holds_marker_query(pid: RawPid, handle: u64) -> MarkerQuery {
let fds = match pipe_fds_of(pid) {
PipeQuery::Found(fds) => fds,
PipeQuery::Gone => return MarkerQuery::NotHeld,
PipeQuery::Denied => return MarkerQuery::Denied,
};
for fd in fds {
match fd_pipe_info(pid, fd) {
FdPipeInfoQuery::Found(info) if info.pipe_handle == handle => return MarkerQuery::Held,
FdPipeInfoQuery::Found(_) => continue,
FdPipeInfoQuery::Absent => {
log::debug!(
"fd marker {handle:#x}: PROC_PIDFDPIPEINFO for pid {pid} fd {fd} (already \
listed as a pipe) came back empty; treating as vanished between the two calls"
);
continue;
}
FdPipeInfoQuery::Denied => {
return MarkerQuery::Denied;
}
}
}
MarkerQuery::NotHeld
}
fn fd_list_buf_bytes(cap: usize, entry: usize) -> std::io::Result<libc::c_int> {
cap.checked_mul(entry)
.and_then(|bytes| libc::c_int::try_from(bytes).ok())
.ok_or_else(|| {
std::io::Error::other(format!(
"a {cap}-entry proc_fdinfo buffer cannot be described in proc_pidinfo's int \
size argument"
))
})
}
pub(crate) fn pipe_fds_of(pid: RawPid) -> PipeQuery {
let entry = std::mem::size_of::<libc::proc_fdinfo>();
let needed = clear_errno_and_call(|| unsafe {
libc::proc_pidinfo(pid as libc::c_int, libc::PROC_PIDLISTFDS, 0, std::ptr::null_mut(), 0)
});
if needed <= 0 {
return classify_pidlistfds_failure();
}
let mut cap = needed as usize / entry + 16;
loop {
let buf_bytes = match fd_list_buf_bytes(cap, entry) {
Ok(b) => b,
Err(e) => {
log::warn!(
"fd marker: pid {pid}'s open-fd count cannot be enumerated ({e}); treating \
as denied for this pass"
);
return PipeQuery::Denied;
}
};
let mut fds: Vec<libc::proc_fdinfo> = vec![unsafe { std::mem::zeroed() }; cap];
let written = clear_errno_and_call(|| unsafe {
libc::proc_pidinfo(
pid as libc::c_int,
libc::PROC_PIDLISTFDS,
0,
fds.as_mut_ptr() as *mut libc::c_void,
buf_bytes,
)
});
if written <= 0 {
return classify_pidlistfds_failure();
}
let count = written as usize / entry;
if count > cap {
log::warn!(
"fd marker: pid {pid}'s proc_pidinfo(PROC_PIDLISTFDS) reported {count} entries \
into a {cap}-entry buffer; treating as denied for this pass"
);
return PipeQuery::Denied;
}
if count == cap {
cap *= 2;
continue;
}
return PipeQuery::Found(
fds[..count]
.iter()
.filter(|f| f.proc_fdtype == libc::PROX_FDTYPE_PIPE as u32)
.map(|f| f.proc_fd)
.collect(),
);
}
}
fn clear_errno_and_call(f: impl FnOnce() -> libc::c_int) -> libc::c_int {
unsafe {
*libc::__error() = 0;
}
f()
}
fn classify_pidlistfds_failure() -> PipeQuery {
let e = std::io::Error::last_os_error();
match e.raw_os_error() {
None | Some(0) => PipeQuery::Found(Vec::new()), Some(libc::ESRCH) => PipeQuery::Gone,
_ => PipeQuery::Denied,
}
}
use std::os::fd::{FromRawFd, OwnedFd, RawFd};
use crate::containment::ContainMode;
pub(crate) fn marker_wanted(mode: Option<ContainMode>, is_root: bool, suppressed: bool) -> bool {
mode.is_some() && is_root && !suppressed
}
const HIGH_FLOOR: RawFd = 64;
pub(crate) fn safe_marker_fd(candidate: RawFd, reserved: &[RawFd]) -> RawFd {
let floor = reserved
.iter()
.copied()
.max()
.map_or(HIGH_FLOOR, |m| m.saturating_add(1))
.max(HIGH_FLOOR);
candidate.max(floor)
}
pub(crate) struct PreparedMarker {
pub read: OwnedFd,
pub handle: u64,
pub read_handle: u64,
#[cfg_attr(not(test), allow(dead_code, reason = "read only by tests"))]
pub fd: RawFd,
}
pub(crate) fn install(std_cmd: &mut std::process::Command, reserved: &[RawFd]) -> Option<PreparedMarker> {
let (read, write) = match create_pipe() {
Ok(p) => p,
Err(e) => {
log::warn!(
"fd marker: pipe() failed ({e}); falling back to the pre-existing containment channel for this mode"
);
return None;
}
};
let want = safe_marker_fd(write.as_fd().as_raw_fd(), reserved);
let write: OwnedFd = match place_write_end(write, want) {
Ok(fd) => fd,
Err(e) => {
log::warn!("fd marker: could not place the marker descriptor ({e}); falling back to the pre-existing containment channel for this mode");
return None;
}
};
let fd = write.as_raw_fd();
debug_assert!(
unsafe { libc::fcntl(fd, libc::F_GETFD) } & libc::FD_CLOEXEC != 0,
"the marker's supervisor-side write-end copy must be FD_CLOEXEC"
);
let Some(handle) = read_handle(write.as_fd()) else {
log::warn!("fd marker: the marker pipe has no readable handle; falling back to the pre-existing containment channel for this mode");
return None;
};
if handle == 0 {
log::warn!("fd marker: the marker pipe's write end reported a zero handle; falling back to the pre-existing containment channel for this mode");
debug_assert!(
false,
"fd marker: pipe_handle_of the write end returned 0, the reserved sentinel"
);
return None;
}
debug_assert!(
matches!(
fd_pipe_info(std::process::id(), read.as_raw_fd()),
FdPipeInfoQuery::Found(info) if info.pipe_peerhandle == handle
),
"the marker's read end must report the write end's handle as its peer"
);
let Some(read_handle_value) = pipe_handle_of(read.as_fd()) else {
log::warn!("fd marker: the marker pipe's read end has no readable handle; falling back to the pre-existing containment channel for this mode");
return None;
};
if read_handle_value == 0 {
log::warn!("fd marker: the marker pipe's read end reported a zero handle; falling back to the pre-existing containment channel for this mode");
debug_assert!(
false,
"fd marker: pipe_handle_of the read end returned 0, the reserved sentinel"
);
return None;
}
crate::child::spawn::fd_map::install_preserved(std_cmd, vec![write]);
Some(PreparedMarker {
read: OwnedFd::from(read),
handle,
read_handle: read_handle_value,
fd,
})
}
fn create_pipe() -> std::io::Result<(std::io::PipeReader, std::io::PipeWriter)> {
#[cfg(test)]
if fault::take_if(fault::Fault::Pipe) {
return Err(std::io::Error::from_raw_os_error(libc::EMFILE));
}
std::io::pipe()
}
fn place_write_end(write: std::io::PipeWriter, want: RawFd) -> Result<OwnedFd, nix::errno::Errno> {
#[cfg(test)]
if fault::take_if(fault::Fault::Place) {
return Err(nix::errno::Errno::EMFILE);
}
let placed = nix::fcntl::fcntl(write.as_fd(), nix::fcntl::FcntlArg::F_DUPFD_CLOEXEC(want))?;
debug_assert!(
placed >= want,
"F_DUPFD_CLOEXEC({want}) returned {placed}, below the floor it was given"
);
Ok(unsafe { OwnedFd::from_raw_fd(placed) })
}
fn read_handle(fd: BorrowedFd<'_>) -> Option<u64> {
#[cfg(test)]
if fault::take_if(fault::Fault::Handle) {
return None;
}
pipe_handle_of(fd)
}
#[cfg(test)]
pub(crate) mod fault {
use std::cell::Cell;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(crate) enum Fault {
Pipe,
Place,
Handle,
}
thread_local! {
static FAULT: Cell<Option<Fault>> = const { Cell::new(None) };
}
pub(crate) fn set_fault(f: Option<Fault>) {
FAULT.with(|c| c.set(f));
}
pub(crate) fn take_if(want: Fault) -> bool {
FAULT.with(|c| {
if c.get() == Some(want) {
c.set(None);
true
} else {
false
}
})
}
pub(crate) fn take_fault() -> Option<Fault> {
FAULT.with(|c| c.take())
}
thread_local! {
static FORCE_ROOT_KILL_NOOP: Cell<bool> = const { Cell::new(false) };
}
pub(crate) fn set_force_root_kill_noop(on: bool) {
FORCE_ROOT_KILL_NOOP.with(|f| f.set(on));
}
pub(crate) fn take_force_root_kill_noop() -> bool {
FORCE_ROOT_KILL_NOOP.with(|f| f.replace(false))
}
pub(crate) fn armed() -> bool {
FORCE_ROOT_KILL_NOOP.with(|f| f.get())
}
thread_local! {
static HOLDER_KILLS: std::cell::RefCell<Option<Vec<u32>>> = const { std::cell::RefCell::new(None) };
}
pub(crate) fn record_holder_kills() -> HolderKillRecorder {
HOLDER_KILLS.with(|k| *k.borrow_mut() = Some(Vec::new()));
HolderKillRecorder(())
}
#[must_use = "recording stops as soon as the recorder is dropped"]
pub(crate) struct HolderKillRecorder(());
impl HolderKillRecorder {
pub(crate) fn killed(&self) -> Vec<u32> {
HOLDER_KILLS.with(|k| k.borrow().clone().expect("the recorder is live"))
}
}
impl Drop for HolderKillRecorder {
fn drop(&mut self) {
HOLDER_KILLS.with(|k| *k.borrow_mut() = None);
}
}
pub(super) fn note_holder_kill(pid: u32) {
HOLDER_KILLS.with(|k| {
if let Some(killed) = k.borrow_mut().as_mut() {
killed.push(pid);
}
});
}
static LOG_SERIALIZE: std::sync::Mutex<()> = std::sync::Mutex::new(());
pub(crate) fn lock_for_log_assertion() -> std::sync::MutexGuard<'static, ()> {
LOG_SERIALIZE.lock().unwrap_or_else(|e| e.into_inner())
}
}
use std::io;
use crate::error::Error;
use crate::identity::{ProcessId, Resolved};
pub(crate) struct Marker {
read: OwnedFd,
handle: u64,
read_handle: u64,
root: ProcessId,
pgid: Option<i32>,
own_fd: RawFd,
}
impl std::fmt::Debug for Marker {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("Marker")
.field("handle", &format_args!("{:#x}", self.handle))
.field("pgid", &self.pgid)
.finish_non_exhaustive()
}
}
pub(crate) fn is_signalable(pid: RawPid) -> bool {
pid > 1 && pid != std::process::id()
}
fn pid_is_live_group_member(pid: RawPid, pgid: i32) -> bool {
debug_assert!(
pid <= i32::MAX as u32,
"pid {pid} exceeds i32::MAX; pgid comparison would truncate"
);
nix::unistd::getpgid(Some(nix::unistd::Pid::from_raw(pid as i32)))
.map(|g| g.as_raw() == pgid)
.unwrap_or(false)
}
pub(crate) fn is_teardown_mechanism_failure(e: &Error) -> bool {
matches!(e, Error::Io(_) | Error::Unsupported { .. }) || matches!(e, Error::Unassessable { source: Some(_), .. })
}
fn combine_group_errors(first: Error, latest: Error) -> Error {
let detail = format!("{first}; {latest}");
if is_teardown_mechanism_failure(&first) || is_teardown_mechanism_failure(&latest) {
Error::Io(io::Error::other(detail))
} else {
Error::Containment { detail }
}
}
impl Marker {
pub(crate) fn new(prepared: PreparedMarker, root: ProcessId, pgid: Option<i32>) -> Marker {
Marker {
read: prepared.read,
handle: prepared.handle,
read_handle: prepared.read_handle,
root,
pgid,
own_fd: prepared.fd,
}
}
#[cfg_attr(
not(test),
allow(dead_code, reason = "consumed by Child::test_marker_handle (test-only)")
)]
pub(crate) fn handle(&self) -> u64 {
self.handle
}
pub(crate) fn own_fd(&self) -> RawFd {
self.own_fd
}
pub(crate) fn has_pgid(&self) -> bool {
self.pgid.is_some()
}
#[cfg(test)]
pub(crate) fn root(&self) -> ProcessId {
self.root
}
pub(crate) fn pgid(&self) -> Option<i32> {
self.pgid
}
#[cfg(test)]
pub(crate) fn force_pgid_for_test(&mut self, pgid: i32) {
self.pgid = Some(pgid);
}
pub(crate) fn read_end(&self) -> BorrowedFd<'_> {
self.read.as_fd()
}
pub(crate) fn wait_drained(
&self,
deadline: Option<Option<Instant>>,
) -> Result<crate::containment::TreeDrain, Error> {
#[cfg(feature = "tokio")]
crate::bounded::assert_may_block("waiting for a marked tree to drain");
self.check_read_end_still_valid()?;
debug_assert_ne!(
crate::containment::marker_eof::write_end_check(self.read_end()),
crate::containment::marker_eof::WriteEndCheck::HeldByUs,
"the supervisor still holds a copy of the marker write end - the tree-drain edge can never fire"
);
crate::containment::marker_eof::block_until_drained(self.read_end(), deadline)
}
pub(crate) fn hard_kill(&self) -> Result<(), Error> {
self.hard_kill_impl(true)
}
pub(crate) fn hard_kill_holders_only(&self) -> Result<(), Error> {
self.hard_kill_impl(false)
}
fn hard_kill_impl(&self, by_root_number: bool) -> Result<(), Error> {
self.check_read_end_still_valid()?;
let mut seen: std::collections::HashSet<ProcessId> = std::collections::HashSet::new();
let mut group_result: Result<(), Error> = Ok(());
let mut incomplete = false;
let mut first_pass = true;
loop {
let progressed = self.sweep_pass(
nix::sys::signal::Signal::SIGKILL,
&mut seen,
&mut group_result,
&mut incomplete,
first_pass,
by_root_number,
);
first_pass = false;
if !progressed {
break;
}
}
Self::finish_sweep(self.handle, group_result, incomplete)
}
pub(crate) fn terminate(&self) -> Result<(), Error> {
self.check_read_end_still_valid()?;
let mut seen: std::collections::HashSet<ProcessId> = std::collections::HashSet::new();
let mut group_result: Result<(), Error> = Ok(());
let mut incomplete = false;
self.sweep_pass(
nix::sys::signal::Signal::SIGTERM,
&mut seen,
&mut group_result,
&mut incomplete,
true,
true,
);
Self::finish_sweep(self.handle, group_result, incomplete)
}
pub(crate) fn check_read_end_still_valid(&self) -> Result<(), Error> {
let read_still_valid = matches!(
fd_pipe_info(std::process::id(), self.read.as_raw_fd()),
FdPipeInfoQuery::Found(info) if info.pipe_handle == self.read_handle
);
debug_assert!(
read_still_valid,
"fd marker {:#x}: the read end must still be the same pipe object at sweep time",
self.handle
);
if !read_still_valid {
let msg = format!(
"fd marker {:#x}: the read end no longer names its recorded pipe object at \
sweep entry — refusing to sweep rather than signal against a handle that may \
now name an unrelated live pipe",
self.handle
);
log::error!("{msg}");
return Err(Error::Io(io::Error::other(msg)));
}
Ok(())
}
fn sweep_pass(
&self,
signal: nix::sys::signal::Signal,
seen: &mut std::collections::HashSet<ProcessId>,
group_result: &mut Result<(), Error>,
incomplete: &mut bool,
first_pass: bool,
by_root_number: bool,
) -> bool {
let (pids, parents, _ppid_denied) = crate::containment::enumerate::snapshot();
let blind = pids.is_empty();
if blind {
*incomplete = true;
if first_pass {
log::warn!(
"fd marker {:#x}: the host process table could not be read on the first \
pass; the ppid-walk and marker channels are blind (the group signal and \
root kill below still run, since neither needs the process table)",
self.handle
);
} else {
log::warn!(
"fd marker {:#x}: the host process table could not be read this pass; \
every channel is blind this pass — the root was already handled on an \
earlier pass and is not retried, and the group signal does not re-fire \
without a live member freshly confirmed THIS pass (not observed this \
pass is not the same as observed absent). This pass performs no teardown \
on any channel",
self.handle
);
}
}
let mut new_walk: Vec<ProcessId> = Vec::new();
if by_root_number {
let root = self.root;
#[cfg(test)]
crate::containment::treewalk::fault::note_walk(root.pid());
if seen.insert(root) {
new_walk.push(root);
}
if !blind {
for id in crate::containment::treewalk::descendants(root, &parents) {
if seen.insert(id) {
new_walk.push(id);
}
}
}
}
let this_pass_holders: Vec<Holder> = if blind { Vec::new() } else { holders(self.handle, &pids) };
let mut new_holders: Vec<ProcessId> = Vec::new();
for h in &this_pass_holders {
if !is_signalable(h.pid) {
log::warn!(
"fd marker {:#x}: self-exclusion guard fired for pid {} found in the \
holder set (the supervisor or pid 0/1 must never hold its own marker)",
self.handle,
h.pid
);
debug_assert!(
false,
"fd marker sweep found pid {} in its own holder set (supervisor, pid 0, or \
pid 1) — the write-end hand-off must never reach any of them",
h.pid
);
continue;
}
let id = match ProcessId::of(h.pid) {
Resolved::Found(id) => id,
Resolved::Gone => continue,
Resolved::Unknown => {
log::warn!(
"fd marker {:#x}: holder pid {} could not be queried (access denied?) \
- not signaled, left running",
self.handle,
h.pid
);
*incomplete = true;
continue;
}
};
if seen.insert(id) {
new_holders.push(id);
}
}
{
let live_holder_confirms_pgid = !blind
&& self.pgid.is_some_and(|pgid| {
this_pass_holders
.iter()
.any(|h| is_signalable(h.pid) && pid_is_live_group_member(h.pid, pgid))
});
let should_fire = first_pass || live_holder_confirms_pgid;
if !by_root_number {
} else if should_fire {
let this_pass_group_result: Result<(), Error> = match (self.pgid, signal) {
(Some(pgid), nix::sys::signal::Signal::SIGKILL) => crate::containment::unix::kill_group(pgid),
(Some(pgid), _) => crate::containment::unix::term_group(pgid),
(None, _) => Ok(()),
};
*group_result = match (std::mem::replace(group_result, Ok(())), this_pass_group_result) {
(Ok(()), r) => r,
(e @ Err(_), Ok(())) => e,
(Err(first), Err(latest)) => Err(combine_group_errors(first, latest)),
};
} else if self.pgid.is_some() {
if blind {
log::debug!(
"fd marker {:#x}: skipping this pass's group signal — the process \
table could not be read this pass, so no live member of this pass's \
pgid was observed (not: none was found)",
self.handle
);
} else {
log::debug!(
"fd marker {:#x}: skipping this pass's group signal — no live member \
confirmed this pass's pgid, so it may have been recycled",
self.handle
);
}
}
}
if new_walk.is_empty() && new_holders.is_empty() {
return false; }
let mut progressed = false;
for id in new_walk {
#[cfg(test)]
if id == self.root && fault::take_force_root_kill_noop() {
continue;
}
if crate::containment::treewalk::kill_by_identity(id, signal)
== crate::containment::treewalk::KillOutcome::NotAttempted
{
*incomplete = true;
} else {
progressed = true;
}
}
for id in new_holders {
if self.kill_holder(id, signal) {
*incomplete = true; } else {
progressed = true; }
}
progressed
}
fn finish_sweep(handle: u64, group_result: Result<(), Error>, incomplete: bool) -> Result<(), Error> {
if incomplete {
let msg = format!(
"fd marker {handle:#x}: teardown may be incomplete — the host process table \
was unreadable on at least one pass, or at least one known/suspected member \
could not be assessed or signalled"
);
let incomplete_err = Error::Unassessable {
detail: msg,
source: None,
};
return match group_result {
Ok(()) => Err(incomplete_err),
Err(group_err) => Err(combine_group_errors(incomplete_err, group_err)),
};
}
group_result
}
fn kill_holder(&self, id: ProcessId, signal: nix::sys::signal::Signal) -> bool {
match holds_marker_query(id.pid(), self.handle) {
MarkerQuery::NotHeld => {
log::debug!(
"fd marker {:#x}: pid {} no longer holds the marker - not signaled",
self.handle,
id.pid()
);
false
}
MarkerQuery::Denied => {
log::warn!(
"fd marker {:#x}: pid {} (a confirmed holder this pass) could not be \
re-queried before signalling (access denied?) - not signaled, left \
running",
self.handle,
id.pid()
);
true
}
MarkerQuery::Held => {
#[cfg(test)]
fault::note_holder_kill(id.pid());
crate::containment::treewalk::kill_by_identity(id, signal)
== crate::containment::treewalk::KillOutcome::NotAttempted
}
}
}
}
#[cfg(test)]
#[path = "fdmarker_tests.rs"]
pub(crate) mod fdmarker_tests;