pub struct ManagedProcess { /* private fields */ }Expand description
Full process lifecycle driven by a caller-owned reactor.
ManagedProcess preserves the blocking spawn semantics while allowing
an application reactor to stay responsive: Core owns timeout/cancellation
escalation, process-group signaling, pipe draining, overflow reporting, and
waitpid reaping; the caller only routes readiness events and polls on
Self::next_deadline.
Implementations§
Source§impl ManagedProcess
impl ManagedProcess
Sourcepub fn pid(&self) -> pid_t
pub fn pid(&self) -> pid_t
Return the child PID.
The PID is captured at spawn time, so this remains available after the process has completed (unlike the running handle, which is consumed).
Sourcepub fn register_with_reactor(
&mut self,
reactor: &mut Reactor,
) -> Result<(), CoreError>
pub fn register_with_reactor( &mut self, reactor: &mut Reactor, ) -> Result<(), CoreError>
Register active child I/O descriptors with the caller’s reactor.
Sourcepub fn handle_reactor_event(
&mut self,
reactor: &mut Reactor,
event: &Event,
) -> Result<(), CoreError>
pub fn handle_reactor_event( &mut self, reactor: &mut Reactor, event: &Event, ) -> Result<(), CoreError>
Route one reactor event to the child’s I/O drain state.
Sourcepub fn stdout_paused(&self) -> bool
pub fn stdout_paused(&self) -> bool
Return whether the stdout stream is paused on a full sink queue.
Sourcepub fn stderr_paused(&self) -> bool
pub fn stderr_paused(&self) -> bool
Return whether the stderr stream is paused on a full sink queue.
Sourcepub fn resume_stdout(
&mut self,
reactor: &mut Reactor,
) -> Result<bool, CoreError>
pub fn resume_stdout( &mut self, reactor: &mut Reactor, ) -> Result<bool, CoreError>
Re-deliver the held stdout chunk (if any) and re-register the fd when
the sink has room again. Returns true when the stream is resumed.
Sourcepub fn resume_stderr(
&mut self,
reactor: &mut Reactor,
) -> Result<bool, CoreError>
pub fn resume_stderr( &mut self, reactor: &mut Reactor, ) -> Result<bool, CoreError>
Re-deliver the held stderr chunk (if any) and re-register the fd when
the sink has room again. Returns true when the stream is resumed.
Sourcepub fn request_cancel(&mut self)
pub fn request_cancel(&mut self)
Request cancellation using the daemon-owned policy from
SpawnOptionsBuilder::cancel. Repeated requests are idempotent.
Sourcepub fn next_deadline(&self) -> Option<Instant>
pub fn next_deadline(&self) -> Option<Instant>
Earliest time at which Self::poll_completion should run again.
A bounded reap tick is returned while the child is live, and exact
timeout / TERM-to-KILL deadlines take precedence. None means the
completion was already consumed.
Sourcepub fn poll_completion(
&mut self,
reactor: &mut Reactor,
) -> Result<Option<Output>, CoreError>
pub fn poll_completion( &mut self, reactor: &mut Reactor, ) -> Result<Option<Output>, CoreError>
Advance timeout/cancellation, reap state, and completion.
Returns Ok(None) while work remains, the normal Output once the
child is reaped and its pipes are drained, or EOVERFLOW when the
configured combined output limit was exceeded on the fully-drained
path. A forced-close (timeout/cancel with a wedged pipe) returns the
partial output and the timed_out flag instead, matching blocking
spawn.
Sourcepub fn resize_pty(&self, rows: u16, cols: u16) -> Result<(), CoreError>
pub fn resize_pty(&self, rows: u16, cols: u16) -> Result<(), CoreError>
Apply a new terminal window size to a pty-spawned child.
Only valid for a SpawnOptionsBuilder::pty spawn with an active
stdout stream; callers typically follow this with a SIGWINCH to the
child (or its foreground group) so the program can re-read the size.
§Errors
EINVAL: The spawn was not a pty spawn, the stream is already closed, orrows/colsis zero.ENOTTY: The pty master is unexpectedly not a terminal.
Sourcepub fn write_input(&self, bytes: &[u8]) -> Result<usize, CoreError>
pub fn write_input(&self, bytes: &[u8]) -> Result<usize, CoreError>
Write bytes to a pty-spawned child’s stdin (the master end).
Only valid for a SpawnOptionsBuilder::pty spawn with an active
stdout stream. See RunningProcess::write_input.
Sourcepub fn write_input_nonblock(
&self,
bytes: &[u8],
) -> Result<Option<usize>, CoreError>
pub fn write_input_nonblock( &self, bytes: &[u8], ) -> Result<Option<usize>, CoreError>
Write bytes to a pty-spawned child’s stdin without blocking.
Only valid for a SpawnOptionsBuilder::pty spawn with an active
stdout stream. See RunningProcess::write_input_nonblock.