pub struct ProcessHandle<O: OutputStream> { /* private fields */ }Implementations§
Source§impl ProcessHandle<BroadcastOutputStream>
impl ProcessHandle<BroadcastOutputStream>
pub fn spawn( name: impl Into<Cow<'static, str>>, cmd: Command, ) -> Result<ProcessHandle<BroadcastOutputStream>>
pub fn spawn_with_capacity( name: impl Into<Cow<'static, str>>, cmd: Command, stdout_channel_capacity: usize, stderr_channel_capacity: usize, ) -> Result<ProcessHandle<BroadcastOutputStream>>
pub async fn wait_with_output( &mut self, options: LineParsingOptions, ) -> Result<(ExitStatus, Vec<String>, Vec<String>), WaitError>
Source§impl ProcessHandle<SingleSubscriberOutputStream>
impl ProcessHandle<SingleSubscriberOutputStream>
pub fn spawn(name: impl Into<Cow<'static, str>>, cmd: Command) -> Result<Self>
pub fn spawn_with_capacity( name: impl Into<Cow<'static, str>>, cmd: Command, stdout_channel_capacity: usize, stderr_channel_capacity: usize, ) -> Result<Self>
pub async fn wait_with_output( &mut self, options: LineParsingOptions, ) -> Result<(ExitStatus, Vec<String>, Vec<String>), WaitError>
Source§impl<O: OutputStream> ProcessHandle<O>
impl<O: OutputStream> ProcessHandle<O>
pub fn id(&self) -> Option<u32>
pub fn is_running(&mut self) -> RunningState
pub fn stdout(&self) -> &O
pub fn stdout_mut(&mut self) -> &mut O
pub fn stderr(&self) -> &O
pub fn stderr_mut(&mut self) -> &mut O
Sourcepub fn must_be_terminated(&mut self)
pub fn must_be_terminated(&mut self)
Sets a panic-on-drop mechanism for this ProcessHandle.
This method enables a safeguard that ensures that the process represented by this
ProcessHandle is properly terminated or awaited before being dropped.
If must_be_terminated is set and the ProcessHandle is
dropped without invoking terminate() or wait(), an intentional panic will occur to
prevent silent failure-states, ensuring that system resources are handled correctly.
You typically do not need to call this, as every ProcessHandle is marked by default.
Call must_not_be_terminated to clear this safeguard to explicitly allow dropping the
process without terminating it.
§Panic
If the ProcessHandle is dropped without being awaited or terminated
after calling this method, a panic will occur with a descriptive message
to inform about the incorrect usage.
pub fn must_not_be_terminated(&mut self)
Sourcepub fn terminate_on_drop(
self,
graceful_termination_timeout: Duration,
forceful_termination_timeout: Duration,
) -> TerminateOnDrop<O>
pub fn terminate_on_drop( self, graceful_termination_timeout: Duration, forceful_termination_timeout: Duration, ) -> TerminateOnDrop<O>
SAFETY: This only works when your code is running in a multithreaded tokio runtime!
Prefer manual termination of the process or awaiting it and relying on the (automatically
configured) must_be_terminated logic, raising a panic when a process was neither awaited
nor terminated before being dropped.
Sourcepub fn send_interrupt_signal(&mut self) -> Result<(), Error>
pub fn send_interrupt_signal(&mut self) -> Result<(), Error>
Manually sed a SIGINT on unix or equivalent on Windows to this process.
Prefer to call terminate instead, if you want to make sure this process is terminated.
Sourcepub fn send_terminate_signal(&mut self) -> Result<(), Error>
pub fn send_terminate_signal(&mut self) -> Result<(), Error>
Manually sed a SIGTERM on unix or equivalent on Windows to this process.
Prefer to call terminate instead, if you want to make sure this process is terminated.
Sourcepub async fn terminate(
&mut self,
interrupt_timeout: Duration,
terminate_timeout: Duration,
) -> Result<ExitStatus, TerminationError>
pub async fn terminate( &mut self, interrupt_timeout: Duration, terminate_timeout: Duration, ) -> Result<ExitStatus, TerminationError>
Terminates this process by sending a SIGINT, SIGTERM or even a SIGKILL if the process
doesn’t run to completion after receiving any of the first two signals.
pub async fn kill(&mut self) -> Result<()>
Sourcepub async fn wait_for_completion(
&mut self,
timeout: Option<Duration>,
) -> Result<ExitStatus>
pub async fn wait_for_completion( &mut self, timeout: Option<Duration>, ) -> Result<ExitStatus>
Wait for this process to run to completion. Within timeout, if set, or unbound otherwise.
pub async fn wait_for_completion_or_terminate( &mut self, wait_timeout: Duration, interrupt_timeout: Duration, terminate_timeout: Duration, ) -> Result<ExitStatus, TerminationError>
Sourcepub fn into_inner(self) -> (Child, O, O)
pub fn into_inner(self) -> (Child, O, O)
Consumes this handle to provide the wrapped tokio::process::Child instance as well as the
stdout and stderr output streams.