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