pub struct Child { /* private fields */ }Expand description
子进程句柄
Implementations§
Source§impl Child
impl Child
Sourcepub fn is_running(&mut self) -> bool
pub fn is_running(&mut self) -> bool
判断进程是否仍在运行
Sourcepub async fn wait(&mut self) -> Result<ExitStatus, ProcessError>
pub async fn wait(&mut self) -> Result<ExitStatus, ProcessError>
等待进程结束
Sourcepub async fn wait_timeout(
&mut self,
timeout: Duration,
) -> Result<Option<ExitStatus>, ProcessError>
pub async fn wait_timeout( &mut self, timeout: Duration, ) -> Result<Option<ExitStatus>, ProcessError>
等待进程结束(带超时)
Sourcepub async fn wait_with_output(self) -> Result<ProcessOutput, ProcessError>
pub async fn wait_with_output(self) -> Result<ProcessOutput, ProcessError>
等待并获取输出
Sourcepub async fn write_stdin(&mut self, data: &[u8]) -> Result<(), ProcessError>
pub async fn write_stdin(&mut self, data: &[u8]) -> Result<(), ProcessError>
向标准输入写入数据
Sourcepub fn close_stdin(&mut self)
pub fn close_stdin(&mut self)
关闭标准输入
Sourcepub async fn read_stdout(&mut self) -> Result<Vec<u8>, ProcessError>
pub async fn read_stdout(&mut self) -> Result<Vec<u8>, ProcessError>
读取标准输出
Sourcepub async fn read_stderr(&mut self) -> Result<Vec<u8>, ProcessError>
pub async fn read_stderr(&mut self) -> Result<Vec<u8>, ProcessError>
读取标准错误
Sourcepub fn terminate(&self) -> Result<(), ProcessError>
pub fn terminate(&self) -> Result<(), ProcessError>
发送终止信号(优雅终止)
Sourcepub fn kill(&mut self) -> Result<(), ProcessError>
pub fn kill(&mut self) -> Result<(), ProcessError>
强制终止进程
Sourcepub fn inner_mut(&mut self) -> &mut TokioChild
pub fn inner_mut(&mut self) -> &mut TokioChild
获取底层 tokio Child 的可变引用
Auto Trait Implementations§
impl Freeze for Child
impl !RefUnwindSafe for Child
impl Send for Child
impl Sync for Child
impl Unpin for Child
impl !UnwindSafe for Child
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
Mutably borrows from an owned value. Read more