From ae865efb275800432d7f64826ee4ecc7b739d233 Mon Sep 17 00:00:00 2001 From: Wesley Merkel Date: Fri, 25 Dec 2020 04:37:20 -0600 Subject: [PATCH] Update signal-hook to version 0.3.0 The dependency on version v0.1.16 of signal-hook makes this library impossible to use in a project alongside signal-hook version v0.3.0. This is caused by an arguably incorrect dependency from signal-hook v0.1.16 on `~1.2` of signal-hook-registry (I think it should just depend on `^1.2` instead), however it seemed more beneficial overall to upgrade this crate's dependency instead. --- Cargo.toml | 6 +++++- src/lib.rs | 10 ++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index afcd8f4..a57a608 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" diff --git a/src/lib.rs b/src/lib.rs index c6017d8..2adbf17 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -186,9 +186,11 @@ impl Child { } } else if #[cfg(unix)] { - static SIGNALS: Lazy = Lazy::new(|| { - signal_hook::iterator::Signals::new(&[signal_hook::SIGCHLD]) - .expect("cannot set signal handler for SIGCHLD") + static SIGNALS: Lazy> = 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.