pub async fn wait_child_any(proc: &Arc<Process>, nonblock: bool) -> LxResult<(KoID, ExitCode)> {
    loop {
        let mut inner = proc.linux().inner.lock();
        if inner.children.is_empty() {
            return Err(LxError::ECHILD);
        }
        for (&pid, child) in inner.children.iter() {
            if let Status::Exited(code) = child.status() {
                inner.children.remove(&pid);
                return Ok((pid, code as ExitCode));
            }
        }
        drop(inner);
        if nonblock {
            return Err(LxError::EAGAIN);
        }
        let proc: Arc<dyn KernelObject> = proc.clone();
        proc.signal_clear(Signal::SIGCHLD);
        //等待进程结束信号
        proc.wait_signal(Signal::SIGCHLD).await;
    }
}
/// Wait for state changes in a child of the calling process.
Wait for state changes in a child of the calling process.
Wait for state changes in a child of the calling process .
pub async fn wait_child_any(proc: &Arc<Process>, nonblock: bool) -> LxResult<(KoID, ExitCode)> {
    loop {
        let mut inner = proc.linux().inner.lock();
        if inner.children.is_empty() {
            return Err(LxError::ECHILD);
        }
        for (&pid, child) in inner.children.iter() {
            if let Status::Exited(code) = child.status() {
                inner.children.remove(&pid);
                return Ok((pid, code as ExitCode));
            }
        }
        drop(inner);
        if nonblock {
            return Err(LxError::EAGAIN);
        }
        let proc: Arc<dyn KernelObject> = proc.clone();
        proc.signal_clear(Signal::SIGCHLD);
        //等待进程结束信号
        proc.wait_signal(Signal::SIGCHLD).await;
    }
}
pub async fn wait_child_any ( proc : & Arc < Process > , nonblock : bool ) -> LxResult < ( KoID , ExitCode ) > { loop { let mut inner = proc . linux ( ) . inner . lock ( ) ; if inner . children . is_empty ( ) { return Err ( LxError :: ECHILD ) ; } for ( & pid , child ) in inner . children . iter ( ) { if let Status :: Exited ( code ) = child . status ( ) { inner . children . remove ( & pid ) ; return Ok ( ( pid , code as ExitCode ) ) ; } } drop ( inner ) ; if nonblock { return Err ( LxError :: EAGAIN ) ; } let proc : Arc < dyn KernelObject > = proc . clone ( ) ; proc . signal_clear ( Signal :: SIGCHLD ) ; //等待进程结束信号 proc . wait_signal ( Signal :: SIGCHLD ) . await ; } }
Wait for state changes in a child of the calling process.
Wait for state changes in a child of the calling process .
proc
&Arc<Process>
nonblock
bool
proc
&Arc<Process>
nonblock
bool