Reset sigmask to fix Rust 1.64 breaking change

See: https://github.com/watchexec/cargo-watch/issues/249
This commit is contained in:
Félix Saparelli 2023-02-13 15:50:59 +13:00
parent e21a3a99f6
commit b5f9f8140a
No known key found for this signature in database
1 changed files with 25 additions and 2 deletions

View File

@ -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(())