Skip to main content

RunningProcess

Struct RunningProcess 

Source
pub struct RunningProcess {
    pub process: Process,
    /* private fields */
}
Expand description

A process that is currently running and being monitored.

§Fork Safety

This handle contains both a PID and owned file descriptors for process I/O. Upon fork, the descriptors are inherited. Standard O_CLOEXEC behavior applies after exec.

Fields§

§process: Process

Handle to the process.

Implementations§

Source§

impl RunningProcess

Source

pub fn register_with_reactor( &mut self, reactor: &mut Reactor, ) -> Result<(), CoreError>

Register active stdio pipe descriptors with a reactor.

Call this once after spawn_start when the process was started with captured output or stdin data. The assigned tokens are kept internally and later matched by Self::handle_reactor_event.

Source

pub fn handle_reactor_event( &mut self, reactor: &mut Reactor, event: &Event, ) -> Result<(), CoreError>

Apply one reactor readiness event to this process’ stdio drain state.

Events for unrelated tokens are ignored. Callers remain responsible for waiting on Self::process and driving the reactor until Self::io_done returns true.

Source

pub fn io_done(&self) -> bool

Return whether all managed stdio pipes have been drained or closed.

Source

pub fn stdout_paused(&self) -> bool

Return whether the stdout stream is paused on a full sink queue.

Source

pub fn stderr_paused(&self) -> bool

Return whether the stderr stream is paused on a full sink queue.

Source

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.

Source

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.

Source

pub fn into_output_parts(self) -> (Vec<u8>, Vec<u8>)

Consume the running process handle and return captured stdout/stderr buffers.

Source

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, or rows/cols is zero.
  • ENOTTY: The pty master is unexpectedly not a terminal.
Source

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; the write is accepted by the tty line discipline and delivered to the child as its stdin.

§Errors
  • EINVAL: The spawn was not a pty spawn, or the stream is already closed.
  • EIO: All slave holders have closed (master-side write failure).
  • ETIMEDOUT: The child did not drain its input within the bound.
Source

pub fn write_input_nonblock( &self, bytes: &[u8], ) -> Result<Option<usize>, CoreError>

Write bytes to a pty-spawned child’s stdin without blocking.

Returns Ok(Some(n)) for the bytes written (may be a partial write when the tty input buffer fills), or Ok(None) on EAGAIN (buffer full). The caller owns the input queue: register POLLOUT interest on the master on EAGAIN and retry on writability.

§Errors
  • EINVAL: The spawn was not a pty spawn, or the stream is already closed.
  • EIO: All slave holders have closed (master-side write failure).
Source

pub fn set_pty_writable( &mut self, reactor: &mut Reactor, writable: bool, ) -> Result<(), CoreError>

Arm or disarm the pty master’s WRITABLE interest (the input route).

Direction-preserving: the readable (output) interest is never touched. The caller arms this when its input queue fills and flushes on each writable event, disarming when the queue drains. See DrainState::set_pty_writable.

§Errors
  • EINVAL: The spawn was not a pty spawn, or the stream is already closed.
Source

pub fn pty_input_token(&self) -> Option<Token>

The pty master’s input-route reactor token, when this is a pty spawn. None for pipe mode (no input route). See DrainState::pty_input_token.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.