Skip to content

Commit

Permalink
Upgrade to event-listener v3.0.0 (#43)
Browse files Browse the repository at this point in the history
Signed-off-by: John Nunley <[email protected]>
  • Loading branch information
notgull authored Sep 10, 2023
1 parent ac1c639 commit 5e8e0b7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ exclude = ["/.*"]
[dependencies]
async-lock = "2.6.0"
cfg-if = "1.0"
event-listener = "2.4.0"
event-listener = "3.0.0"
futures-lite = "1.11.0"

[target.'cfg(unix)'.dependencies]
Expand Down
17 changes: 12 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ use std::os::unix::io::{AsFd, AsRawFd, BorrowedFd, OwnedFd, RawFd};
use blocking::Unblock;

use async_lock::OnceCell;
use event_listener::Event;
use event_listener::{Event, EventListener};
use futures_lite::{future, io, prelude::*};

#[doc(no_inline)]
Expand Down Expand Up @@ -381,14 +381,21 @@ impl Child {
let child = self.child.clone();

async move {
let mut listener = None;
let listener = EventListener::new(&SIGCHLD);
let mut listening = false;
futures_lite::pin!(listener);

loop {
if let Some(status) = child.lock().unwrap().get_mut().try_wait()? {
return Ok(status);
}
match listener.take() {
None => listener = Some(SIGCHLD.listen()),
Some(listener) => listener.await,

if listening {
listener.as_mut().await;
listening = false;
} else {
listener.as_mut().listen();
listening = true;
}
}
}
Expand Down

0 comments on commit 5e8e0b7

Please sign in to comment.