Merge pull request #4 from ooesili/update-signal-hook

Update signal-hook to version 0.3.0
This commit is contained in:
Taiki Endo 2020-12-29 20:01:12 +09:00 committed by GitHub
commit b83f51aa7f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 5 deletions

View File

@ -20,7 +20,11 @@ once_cell = "1.4.1"
[target.'cfg(unix)'.dependencies]
async-io = "1.0.0"
signal-hook = { version = "0.1.16", default-features = false }
[target.'cfg(unix)'.dependencies.signal-hook]
version = "0.3.0"
features = ["iterator"]
default-features = false
[target.'cfg(windows)'.dependencies]
blocking = "1.0.0"

View File

@ -186,9 +186,11 @@ impl Child {
}
} else if #[cfg(unix)] {
static SIGNALS: Lazy<signal_hook::iterator::Signals> = Lazy::new(|| {
signal_hook::iterator::Signals::new(&[signal_hook::SIGCHLD])
.expect("cannot set signal handler for SIGCHLD")
static SIGNALS: Lazy<Mutex<signal_hook::iterator::Signals>> = Lazy::new(|| {
Mutex::new(
signal_hook::iterator::Signals::new(&[signal_hook::consts::SIGCHLD])
.expect("cannot set signal handler for SIGCHLD"),
)
});
// Make sure the signal handler is registered before interacting with the process.
@ -196,7 +198,7 @@ impl Child {
// Waits for the next SIGCHLD signal.
fn wait_sigchld() {
SIGNALS.forever().next();
SIGNALS.lock().unwrap().forever().next();
}
// Wraps a sync I/O type into an async I/O type.