Skip to content

Commit

Permalink
Fix random error in missing_attribute test
Browse files Browse the repository at this point in the history
  • Loading branch information
CrabeDeFrance committed Dec 22, 2024
1 parent ee09cce commit 33bf76e
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1177,13 +1177,25 @@ impl RTShark {
}

/// Check if process is stopped, get the exit code and return true if stopped.
/// Why not doing a simple wait ?
fn try_wait_has_exited(child: &mut Child) -> bool {
#[cfg(target_family = "unix")]
let value =
matches!(child.try_wait(), Ok(Some(s)) if s.code().is_some() || s.signal().is_some());
#[cfg(target_family = "windows")]
let value = matches!(child.try_wait(), Ok(Some(s)) if s.code().is_some() );
value
let mut count = 3;
while count != 0 {
#[cfg(target_family = "unix")]
if let Ok(Some(s)) = child.try_wait() {
return s.code().is_some() || s.signal().is_some();
}

#[cfg(target_family = "windows")]
if let Ok(Some(s)) = child.try_wait() {
return s.code().is_some();
}

std::thread::sleep(std::time::Duration::from_millis(100));
count -= 1;
}

false
}
}

Expand Down

0 comments on commit 33bf76e

Please sign in to comment.