pub trait ProcessHandle: Send {
// Required methods
fn pid(&self) -> Option<u32>;
fn process_group_id(&self) -> Option<u32>;
fn killer(&self) -> Arc<dyn ProcessKiller> ⓘ;
fn take_stdin(&mut self) -> Option<Box<dyn Write + Send>>;
fn take_stdout(&mut self) -> Option<Box<dyn Read + Send>>;
fn take_stderr(&mut self) -> Option<Box<dyn Read + Send>>;
fn wait_with_timeout(
&mut self,
timeout: Option<Duration>,
interrupt: &dyn Fn() -> bool,
) -> Result<WaitOutcome>;
fn wait(&mut self) -> Result<ExitStatus>;
}Expand description
Handle to a running (or finished) process. Used by both the synchronous
proc::run path and the long-running waiter thread.
The trait is intentionally small: the legacy code already managed stdout/stderr drain on dedicated threads, and stdin is written once after spawn — wrapping those reads/writes via boxed trait objects keeps the real and mock paths uniform without forcing async into the rest of the hostlib.
Required Methods§
Sourcefn process_group_id(&self) -> Option<u32>
fn process_group_id(&self) -> Option<u32>
OS process group id, when available. Falls back to Self::pid on
platforms that don’t expose process groups.
Sourcefn killer(&self) -> Arc<dyn ProcessKiller> ⓘ
fn killer(&self) -> Arc<dyn ProcessKiller> ⓘ
Returns a killer that can terminate the process even after the stdout/stderr/wait halves have been moved into the waiter thread.
Sourcefn take_stdin(&mut self) -> Option<Box<dyn Write + Send>>
fn take_stdin(&mut self) -> Option<Box<dyn Write + Send>>
Take ownership of the stdin pipe, if the spawn requested one.
Sourcefn wait_with_timeout(
&mut self,
timeout: Option<Duration>,
interrupt: &dyn Fn() -> bool,
) -> Result<WaitOutcome>
fn wait_with_timeout( &mut self, timeout: Option<Duration>, interrupt: &dyn Fn() -> bool, ) -> Result<WaitOutcome>
Wait for the process to exit, optionally with a timeout, while
polling interrupt. On timeout the spawner kills the child
(SIGKILL, historical semantics) and reports
WaitOutcome::TimedOut. When interrupt returns true (scope
cancellation, deadline expiry — see harn_vm::op_interrupt) the
spawner gracefully terminates the child’s process group (SIGTERM,
then SIGKILL after harn_vm::op_interrupt::SUBPROCESS_TERM_GRACE)
and reports WaitOutcome::Interrupted.
Sourcefn wait(&mut self) -> Result<ExitStatus>
fn wait(&mut self) -> Result<ExitStatus>
Block until the process exits, no timeout, no interrupt polling.
Used by the background (background: true) waiter thread, whose
children deliberately outlive scope cancellation and deadlines.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".