Skip to main content

ProcessHandle

Trait ProcessHandle 

Source
pub trait ProcessHandle: Send {
    // Required methods
    fn write_input(&mut self, bytes: &[u8]) -> Result<(), PtyError>;
    fn resize(&mut self, size: PtySize) -> Result<(), PtyError>;
    fn pause(&mut self) -> Result<(), PtyError>;
    fn resume(&mut self) -> Result<(), PtyError>;
    fn kill(&mut self) -> Result<(), PtyError>;

    // Provided methods
    fn process_id(&self) -> Option<u32> { ... }
    fn terminate(
        &mut self,
        _signal: StopSignal,
        _grace: Duration,
    ) -> Result<(), PtyError> { ... }
}
Expand description

Handle to a spawned process: write input, resize, or terminate it.

Required Methods§

Source

fn write_input(&mut self, bytes: &[u8]) -> Result<(), PtyError>

Writes raw input bytes to the process’s PTY.

§Errors

Returns a PtyError if the write fails.

Source

fn resize(&mut self, size: PtySize) -> Result<(), PtyError>

Resizes the process’s PTY.

§Errors

Returns a PtyError if the resize fails.

Source

fn pause(&mut self) -> Result<(), PtyError>

Suspends the process (SIGSTOP-equivalent), leaving it alive.

§Errors

Returns a PtyError if the signal cannot be sent.

Source

fn resume(&mut self) -> Result<(), PtyError>

Resumes a previously suspended process (SIGCONT-equivalent).

§Errors

Returns a PtyError if the signal cannot be sent.

Source

fn kill(&mut self) -> Result<(), PtyError>

Forcibly terminates the process.

§Errors

Returns a PtyError if the kill signal cannot be sent.

Provided Methods§

Source

fn process_id(&self) -> Option<u32>

The OS process ID of the spawned child, when the platform exposes it. Defaults to unknown so simple test doubles need not invent one.

Source

fn terminate( &mut self, _signal: StopSignal, _grace: Duration, ) -> Result<(), PtyError>

Requests graceful process termination with signal and grace, falling back to Self::kill for adapters without a distinct mechanism.

§Errors

Returns a PtyError if the termination signal cannot be sent.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§