Track agent child processes, reap on completion
spawn_agent returns Child handle + log_path. AgentCycleState stores the Child, polls with try_wait() on each trigger to detect completion. No more filesystem scanning to track agent lifecycle. AgentSnapshot (Clone) sent to TUI for display. AgentInfo holds the Child handle and stays in the state. Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
parent
54ea7824d8
commit
9ac50bd999
5 changed files with 71 additions and 32 deletions
|
|
@ -252,9 +252,9 @@ pub fn scan_pid_files(state_dir: &std::path::Path, timeout_secs: u64) -> Vec<(St
|
|||
|
||||
/// Spawn an agent asynchronously. Writes the pid file before returning
|
||||
/// so the caller immediately sees the agent as running.
|
||||
/// Spawn result: pid and path to the agent's log file.
|
||||
/// Spawn result: child process handle and log path.
|
||||
pub struct SpawnResult {
|
||||
pub pid: u32,
|
||||
pub child: std::process::Child,
|
||||
pub log_path: PathBuf,
|
||||
}
|
||||
|
||||
|
|
@ -287,7 +287,7 @@ pub fn spawn_agent(
|
|||
let pid = child.id();
|
||||
let pid_path = state_dir.join(format!("pid-{}", pid));
|
||||
fs::write(&pid_path, first_phase).ok();
|
||||
Some(SpawnResult { pid, log_path })
|
||||
Some(SpawnResult { child, log_path })
|
||||
}
|
||||
|
||||
fn run_one_agent_inner(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue