fn wait(&mut self, timeout: Duration) -> Option<(Status, Duration)> {
        let duration = self.started_at.elapsed();
        let mut maybe_status = match waitpid(Some(self.pid), Some(WaitPidFlag::WNOHANG)).unwrap() {
            WaitStatus::Exited(_, code) => Some(if code == 0 {
                (Status::Success, duration)
            } else {
                (Status::Failure(code), duration)
            }),
            WaitStatus::Signaled(_, sig, _) => {
                // When a child returned through a signal, there's high chances
                // that said child did not perform any cleanup. We'll send a SIGKILL
                // to its process group just in case.
                killpg(self.pid, Signal::SIGKILL).unwrap();
                Some((Status::Signaled(sig.as_str()), duration))
            }
            _ => None,
        };

        if maybe_status.is_none() && duration >= timeout {
            killpg(self.pid, Signal::SIGKILL).unwrap();
            maybe_status = Some((Status::Timeout, duration));
        }

        maybe_status
    }
/// Calls `waitpid` for the given [RunningPot] and decides whether to
/// terminate the pot because it has been running for too long.
Calls `waitpid` for the given [RunningPot] and decides whether to
terminate the pot because it has been running for too long.
Calls ` waitpid ` for the given [ RunningPot ] and decides whether to terminate the pot because it has been running for too long .
fn wait(&mut self, timeout: Duration) -> Option<(Status, Duration)> {
        let duration = self.started_at.elapsed();
        let mut maybe_status = match waitpid(Some(self.pid), Some(WaitPidFlag::WNOHANG)).unwrap() {
            WaitStatus::Exited(_, code) => Some(if code == 0 {
                (Status::Success, duration)
            } else {
                (Status::Failure(code), duration)
            }),
            WaitStatus::Signaled(_, sig, _) => {
                // When a child returned through a signal, there's high chances
                // that said child did not perform any cleanup. We'll send a SIGKILL
                // to its process group just in case.
                killpg(self.pid, Signal::SIGKILL).unwrap();
                Some((Status::Signaled(sig.as_str()), duration))
            }
            _ => None,
        };
        if maybe_status.is_none() && duration >= timeout {
            killpg(self.pid, Signal::SIGKILL).unwrap();
            maybe_status = Some((Status::Timeout, duration));
        }
        maybe_status
    }
fn wait ( & mut self , timeout : Duration ) -> Option < ( Status , Duration ) > { let duration = self . started_at . elapsed ( ) ; let mut maybe_status = match waitpid ( Some ( self . pid ) , Some ( WaitPidFlag :: WNOHANG ) ) . unwrap ( ) { WaitStatus :: Exited ( _ , code ) => Some ( if code == 0 { ( Status :: Success , duration ) } else { ( Status :: Failure ( code ) , duration ) } ) , WaitStatus :: Signaled ( _ , sig , _ ) => { // When a child returned through a signal, there's high chances // that said child did not perform any cleanup. We'll send a SIGKILL // to its process group just in case. killpg ( self . pid , Signal :: SIGKILL ) . unwrap ( ) ; Some ( ( Status :: Signaled ( sig . as_str ( ) ) , duration ) ) } _ => None , } ; if maybe_status . is_none ( ) && duration >= timeout { killpg ( self . pid , Signal :: SIGKILL ) . unwrap ( ) ; maybe_status = Some ( ( Status :: Timeout , duration ) ) ; } maybe_status }
Calls `waitpid` for the given [RunningPot] and decides whether to
terminate the pot because it has been running for too long.
Calls ` waitpid ` for the given [ RunningPot ] and decides whether to terminate the pot because it has been running for too long .
&mut self
timeout
Duration
&mut self
timeout
Duration