Skip to main content

processes_inside

Function processes_inside 

Source
pub fn processes_inside(dirs: &[&Path]) -> Option<Vec<bool>>
Expand description

Which of these directories has a process working inside it right now, one answer per directory in the order given.

lsof -a -d cwd asks the kernel which processes have their working directory where, which is the only reading that is true at the moment it is taken: the modification time of a work tree is not, and two of the four swept on 2026-09-15 looked untouched since the 12th with live processes inside them. One lsof answers for every directory. None is not knowing — no lsof, or a directory that cannot be resolved — and never “nothing is running”.

use majordomus_cli::worktree::state::processes_inside;
let here = std::env::current_dir().unwrap();
if let Some(answers) = processes_inside(&[here.as_path()]) {
    assert_eq!(answers, vec![true], "this process works inside its own directory");
}