pub struct ProcessManager { /* private fields */ }Expand description
Coordinates process spawning, exit observation, and process-wide child reaping.
Implementations§
Source§impl ProcessManager
impl ProcessManager
Sourcepub fn get() -> AgentdResult<Arc<Self>>
pub fn get() -> AgentdResult<Arc<Self>>
Returns the process-wide manager, starting its SIGCHLD thread on first use.
The first call blocks synchronously until the dedicated thread has built
its runtime and installed the SIGCHLD listener.
§Errors
Returns an error if the thread, runtime, or signal listener cannot start, or if the process manager has terminated unexpectedly.
Sourcepub fn spawn_guard(&self) -> AgentdResult<ProcessSpawnGuard<'_>>
pub fn spawn_guard(&self) -> AgentdResult<ProcessSpawnGuard<'_>>
Opens a spawn section that must end by tracking the child PID.
The returned guard serializes the short spawn-to-registration window with reaping. Production exec requests are already spawned serially by the agent loop, so allowing parallel spawns here adds complexity without throughput.
§Errors
Returns an error if the process manager has terminated.
Sourcepub fn subscribe_failure(&self) -> AgentdResult<Receiver<Option<String>>>
pub fn subscribe_failure(&self) -> AgentdResult<Receiver<Option<String>>>
Subscribes to terminal process-manager failures.
The receiver is created before checking current state so a failure cannot occur between the check and subscription without being observed.
Sourcepub fn signal_process_group(
&self,
identity: ProcessIdentity,
signum: i32,
) -> AgentdResult<()>
pub fn signal_process_group( &self, identity: ProcessIdentity, signum: i32, ) -> AgentdResult<()>
Signals a tracked process group only while its registration is current.
Holding the state lock across the identity check and kill prevents a
reaped PID from being registered to a new session in between them.