Reset process sigmask for Rust 1.66 (#494)
This commit is contained in:
parent
2c06f06ee1
commit
90eb9cae03
|
@ -374,7 +374,7 @@ version = "2.0.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "41aa24cc5e1d6b3fc49ad4cd540b522fedcbe88bc6f259ff16e20e7010b6f8c7"
|
||||
dependencies = [
|
||||
"nix 0.26.1",
|
||||
"nix 0.26.2",
|
||||
"terminfo",
|
||||
"thiserror",
|
||||
"which",
|
||||
|
@ -388,7 +388,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "026c3922235f9f7d78f21251a026f3acdeb7cce3deba107fe09a4bfa63d850a2"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"nix 0.26.1",
|
||||
"nix 0.26.2",
|
||||
"tokio",
|
||||
"winapi",
|
||||
]
|
||||
|
@ -1324,6 +1324,15 @@ dependencies = [
|
|||
"autocfg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "memoffset"
|
||||
version = "0.7.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "miette"
|
||||
version = "5.3.0"
|
||||
|
@ -1407,18 +1416,20 @@ dependencies = [
|
|||
"cc",
|
||||
"cfg-if 1.0.0",
|
||||
"libc",
|
||||
"memoffset",
|
||||
"memoffset 0.6.5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nix"
|
||||
version = "0.26.1"
|
||||
version = "0.26.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "46a58d1d356c6597d08cde02c2f09d785b09e28711837b1ed667dc652c08a694"
|
||||
checksum = "bfdda3d196821d6af13126e40375cdf7da646a96114af134d5f417a9a1dc8e1a"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"cfg-if 1.0.0",
|
||||
"libc",
|
||||
"memoffset 0.7.1",
|
||||
"pin-utils",
|
||||
"static_assertions",
|
||||
]
|
||||
|
||||
|
@ -2646,6 +2657,7 @@ dependencies = [
|
|||
"futures",
|
||||
"ignore-files",
|
||||
"miette",
|
||||
"nix 0.26.2",
|
||||
"normalize-path",
|
||||
"notify",
|
||||
"once_cell",
|
||||
|
|
|
@ -57,5 +57,9 @@ features = [
|
|||
version = "0.1.26"
|
||||
features = ["log"]
|
||||
|
||||
[target.'cfg(unix)'.dependencies.nix]
|
||||
version = "0.26.2"
|
||||
features = ["signal"]
|
||||
|
||||
[dev-dependencies]
|
||||
tracing-subscriber = "0.3.6"
|
||||
|
|
|
@ -282,6 +282,26 @@ async fn spawn_process(
|
|||
let mut spawnable = command.to_spawnable()?;
|
||||
spawnable.kill_on_drop(true);
|
||||
|
||||
// Required from Rust 1.66:
|
||||
// https://github.com/rust-lang/rust/pull/101077
|
||||
//
|
||||
// We do that before the pre-spawn so that hook can be used to set a different mask if wanted.
|
||||
#[cfg(unix)]
|
||||
{
|
||||
use nix::sys::signal::{sigprocmask, SigSet, SigmaskHow, Signal};
|
||||
unsafe {
|
||||
spawnable.pre_exec(|| {
|
||||
let mut oldset = SigSet::empty();
|
||||
let mut newset = SigSet::all();
|
||||
newset.remove(Signal::SIGHUP); // leave SIGHUP alone so nohup works
|
||||
debug!(unblocking=?newset, "resetting process sigmask");
|
||||
sigprocmask(SigmaskHow::SIG_UNBLOCK, Some(&newset), Some(&mut oldset))?;
|
||||
debug!(?oldset, "sigmask reset");
|
||||
Ok(())
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
debug!("running pre-spawn handler");
|
||||
Ok(PreSpawn::new(
|
||||
command.clone(),
|
||||
|
|
|
@ -96,7 +96,6 @@
|
|||
#![doc(html_logo_url = "https://watchexec.github.io/logo:watchexec.svg")]
|
||||
#![warn(clippy::unwrap_used, missing_docs)]
|
||||
#![deny(rust_2018_idioms)]
|
||||
#![forbid(unsafe_code)]
|
||||
|
||||
// the toolkit to make your own
|
||||
pub mod action;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
use std::str::FromStr;
|
||||
|
||||
#[cfg(unix)]
|
||||
use command_group::Signal as NixSignal;
|
||||
use nix::sys::signal::Signal as NixSignal;
|
||||
|
||||
use crate::error::SignalParseError;
|
||||
|
||||
|
@ -82,14 +82,12 @@ pub enum SubSignal {
|
|||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// # // we don't have a direct nix dependency, so we fake it... rather horribly
|
||||
/// # mod nix { pub mod sys { pub mod signal {
|
||||
/// # #[cfg(unix)] pub use command_group::Signal;
|
||||
/// # #[cfg(not(unix))] #[repr(i32)] pub enum Signal { SIGABRT = 6 }
|
||||
/// # } } }
|
||||
/// # #[cfg(unix)]
|
||||
/// # {
|
||||
/// use watchexec::signal::process::SubSignal;
|
||||
/// use nix::sys::signal::Signal;
|
||||
/// assert_eq!(SubSignal::Custom(6), SubSignal::from(Signal::SIGABRT as i32));
|
||||
/// # }
|
||||
/// ```
|
||||
///
|
||||
/// On Unix the [`from_nix`][SubSignal::from_nix] method should be preferred if converting from
|
||||
|
@ -98,8 +96,6 @@ pub enum SubSignal {
|
|||
/// ```
|
||||
/// # #[cfg(unix)]
|
||||
/// # {
|
||||
/// # // we don't have a direct nix dependency, so we fake it... rather horribly
|
||||
/// # mod nix { pub mod sys { pub mod signal { pub use command_group::Signal; } } }
|
||||
/// use watchexec::signal::process::SubSignal;
|
||||
/// use nix::sys::signal::Signal;
|
||||
/// assert_eq!(SubSignal::Custom(6), SubSignal::from_nix(Signal::SIGABRT));
|
||||
|
|
Loading…
Reference in New Issue