use std::io::Result;
use nix::sys::signal::{SigSet, SigmaskHow, sigprocmask};
use tokio::process::Command;
#[cfg(feature = "tracing")]
use tracing::trace;
use super::{CommandWrap, CommandWrapper};
#[derive(Clone, Copy, Debug)]
pub struct ResetSigmask;
impl CommandWrapper for ResetSigmask {
fn pre_spawn(&mut self, command: &mut Command, _core: &CommandWrap) -> Result<()> {
unsafe {
command.pre_exec(|| {
let mut oldset = SigSet::empty();
let newset = SigSet::all();
#[cfg(feature = "tracing")]
trace!(unblocking=?newset, "resetting process sigmask");
sigprocmask(SigmaskHow::SIG_UNBLOCK, Some(&newset), Some(&mut oldset))?;
#[cfg(feature = "tracing")]
trace!(?oldset, "sigmask reset");
Ok(())
});
}
Ok(())
}
}