pub struct ProcessHandle {
pub command: String,
/* private fields */
}Expand description
Non-blocking process handle. Pipe readers run immediately after spawning.
Fields§
§command: StringImplementations§
Source§impl ProcessHandle
impl ProcessHandle
Sourcepub const fn with_pipe_drain(self, pipe_drain: Option<Duration>) -> Self
pub const fn with_pipe_drain(self, pipe_drain: Option<Duration>) -> Self
Bound the wait for open pipes after the wrapper exits; None waits
until every holder closes them.
Sourcepub const fn pid(&self) -> Option<u32>
pub const fn pid(&self) -> Option<u32>
Process id of the wrapper shell, which also leads the process group.
Sourcepub async fn wait_for_exit(&mut self) -> Result<i32>
pub async fn wait_for_exit(&mut self) -> Result<i32>
Wait for process completion and all output, preserving exact bytes as UTF-8.
Ends a piped stdin first: nothing can write while this borrows the handle, and a tool reading stdin would otherwise never exit.
Sourcepub async fn terminate(&mut self) -> Result<()>
pub async fn terminate(&mut self) -> Result<()>
Terminate the command and its Unix process group with SIGTERM,
escalating to SIGKILL after DEFAULT_KILL_AFTER.
Sourcepub async fn terminate_with(
&mut self,
signal: &str,
kill_after: Option<Duration>,
) -> Result<bool>
pub async fn terminate_with( &mut self, signal: &str, kill_after: Option<Duration>, ) -> Result<bool>
Send signal to the process group while any member is alive, even
after the wrapper shell exited. Unless the signal is SIGKILL,
kill_after sends SIGKILL to a group that is still alive then.
Returns whether a signal was sent.
Sourcepub fn get_output(&self) -> (&str, &str, Option<i32>)
pub fn get_output(&self) -> (&str, &str, Option<i32>)
Get collected output after waiting for completion.
Sourcepub fn peek_stdout(&self) -> String
pub fn peek_stdout(&self) -> String
Stdout read so far, also while the process runs.
Sourcepub const fn signal(&self) -> Option<&'static str>
pub const fn signal(&self) -> Option<&'static str>
Signal that ended the process, after waiting for completion.
Sourcepub fn try_wait(&mut self) -> Result<bool>
pub fn try_wait(&mut self) -> Result<bool>
Whether the wrapper process has exited, without waiting for it.
Sourcepub const fn has_exited(&self) -> bool
pub const fn has_exited(&self) -> bool
Check whether completion has been collected.
Sourcepub const fn has_stdin(&self) -> bool
pub const fn has_stdin(&self) -> bool
Whether stdin is piped and still open (see start_command_with_stdin).
Sourcepub async fn write_stdin(&mut self, data: &str) -> Result<()>
pub async fn write_stdin(&mut self, data: &str) -> Result<()>
Write to the piped stdin and flush.
Fails when stdin was not piped, was ended, or the process exited
(BrokenPipe).
Auto Trait Implementations§
impl !Freeze for ProcessHandle
impl !RefUnwindSafe for ProcessHandle
impl !UnwindSafe for ProcessHandle
impl Forget for ProcessHandle
impl Move for ProcessHandle
impl Send for ProcessHandlewhere
RawVecInner: Send,
I32NotAllOnes: Send,
ReusableBoxFuture<Receiver<()>>: Send,
Registration: Send,
Atomic<usize>: Send,
JoinHandle<Result<ExitStatus, Error>>: Send,
Arc<Mutex<Duration>>: Send,
Arc<Atomic<bool>>: Send,
JoinHandle<Result<(), Error>>: Send,
Arc<Mutex<Vec<u8>>>: Send,
&'static str: Send,
impl Sync for ProcessHandle
impl Unpin for ProcessHandlewhere
*const u8 is !null: Unpin,
I32NotAllOnes: Unpin,
ReusableBoxFuture<Receiver<()>>: Unpin,
Arc<Handle>: Unpin,
Arc<Handle>: Unpin,
Arc<ScheduledIo>: Unpin,
Align8<usize>: Unpin,
JoinHandle<Result<ExitStatus, Error>>: Unpin,
Arc<Mutex<Duration>>: Unpin,
Arc<Atomic<bool>>: Unpin,
JoinHandle<Result<(), Error>>: Unpin,
Arc<Mutex<Vec<u8>>>: Unpin,
&'static str: Unpin,
impl UnsafeUnpin for ProcessHandlewhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
I32NotAllOnes: UnsafeUnpin,
*const dyn Future<Output = Receiver<()>> + Send is !null: UnsafeUnpin,
*const ArcInner<Handle> is !null: UnsafeUnpin,
PhantomData<ArcInner<Handle>>: UnsafeUnpin,
*const ArcInner<Handle> is !null: UnsafeUnpin,
PhantomData<ArcInner<Handle>>: UnsafeUnpin,
*const ArcInner<ScheduledIo> is !null: UnsafeUnpin,
PhantomData<ArcInner<ScheduledIo>>: UnsafeUnpin,
Align8<usize>: UnsafeUnpin,
*const Header is !null: UnsafeUnpin,
PhantomData<Result<ExitStatus, Error>>: UnsafeUnpin,
*const ArcInner<Mutex<Duration>> is !null: UnsafeUnpin,
PhantomData<ArcInner<Mutex<Duration>>>: UnsafeUnpin,
*const ArcInner<Atomic<bool>> is !null: UnsafeUnpin,
PhantomData<ArcInner<Atomic<bool>>>: UnsafeUnpin,
PhantomData<Result<(), Error>>: UnsafeUnpin,
*const ArcInner<Mutex<Vec<u8>>> is !null: UnsafeUnpin,
PhantomData<ArcInner<Mutex<Vec<u8>>>>: UnsafeUnpin,
&'static str: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.