From b5f9f8140a703007d817aaa506676dc63b2fa946 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fe=CC=81lix=20Saparelli?= Date: Mon, 13 Feb 2023 15:50:59 +1300 Subject: [PATCH] Reset sigmask to fix Rust 1.64 breaking change See: https://github.com/watchexec/cargo-watch/issues/249 --- lib/src/run.rs | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/lib/src/run.rs b/lib/src/run.rs index 253b89c..947ba92 100644 --- a/lib/src/run.rs +++ b/lib/src/run.rs @@ -269,11 +269,34 @@ impl ExecHandler { } } + // Required from Rust 1.64: + // https://github.com/rust-lang/rust/pull/101077 + #[cfg(unix)] + { + use nix::sys::signal::{sigprocmask, SigSet, SigmaskHow}; + use std::os::unix::process::CommandExt; + unsafe { + command.pre_exec(|| { + let mut oldset = SigSet::empty(); + let mut newset = SigSet::all(); + newset.remove(Signal::SIGHUP); // leave SIGHUP alone so nohup works + debug!("Resetting process sigmask, unblocking {:?}", newset); + sigprocmask(SigmaskHow::SIG_UNBLOCK, Some(&newset), Some(&mut oldset))?; + debug!("Old sigmask: {:?}", oldset); + Ok(()) + }); + } + } + debug!("Launching command"); *child = if self.args.use_process_group { - ChildProcess::Grouped(command.group_spawn()?) + let child = command.group_spawn()?; + debug!("Child process ID: {:?}", child.id()); + ChildProcess::Grouped(child) } else { - ChildProcess::Ungrouped(command.spawn()?) + let child = command.spawn()?; + debug!("Child process ID: {:?}", child.id()); + ChildProcess::Ungrouped(child) }; Ok(())