pub struct ProcessHandle { /* private fields */ }Expand description
Handle for driving an interactive or non-interactive process.
This provides a unified interface for both PTY and pipe-based processes:
- Write to stdin via
writer_sender() - Read merged stdout/stderr via
output_receiver() - Check exit status via
has_exited()andexit_code() - Clean up via
terminate()
Implementations§
Source§impl ProcessHandle
impl ProcessHandle
Sourcepub fn writer_sender(&self) -> Sender<Vec<u8>>
pub fn writer_sender(&self) -> Sender<Vec<u8>>
Sourcepub fn output_receiver(&self) -> Receiver<Bytes>
pub fn output_receiver(&self) -> Receiver<Bytes>
Returns a broadcast receiver that yields stdout/stderr chunks.
Multiple receivers can be created; each receives all output from the point of subscription.
Sourcepub fn has_exited(&self) -> bool
pub fn has_exited(&self) -> bool
True if the child process has exited.
Sourcepub fn is_output_drained(&self) -> bool
pub fn is_output_drained(&self) -> bool
True once the stdout/stderr reader task has drained the child streams.
Sourcepub fn terminate(&self)
pub fn terminate(&self)
Attempts to kill the child and abort helper tasks.
This is idempotent and safe to call multiple times.
Sourcepub fn terminate_process(&self)
pub fn terminate_process(&self)
Kill the child process group without aborting the readers or wait task.
Session owners use this path when they still need to drain output and
reap the child after termination. Call Self::terminate when the
caller is abandoning the session and does not need that final drain.
Sourcepub fn is_running(&self) -> bool
pub fn is_running(&self) -> bool
Check if the process is still running.
Sourcepub async fn write(
&self,
bytes: impl Into<Vec<u8>>,
) -> Result<(), SendError<Vec<u8>>>
pub async fn write( &self, bytes: impl Into<Vec<u8>>, ) -> Result<(), SendError<Vec<u8>>>
Send bytes to the process stdin.
Returns an error if the stdin channel is closed.
Sourcepub fn is_writer_closed(&self) -> bool
pub fn is_writer_closed(&self) -> bool
Check if the writer channel is closed.