process_wrap/std/
reset_sigmask.rs1use std::{io::Result, os::unix::process::CommandExt, process::Command};
2
3use nix::sys::signal::{sigprocmask, SigSet, SigmaskHow};
4#[cfg(feature = "tracing")]
5use tracing::trace;
6
7use super::{CommandWrap, CommandWrapper};
8
9#[derive(Clone, Copy, Debug)]
14pub struct ResetSigmask;
15
16impl CommandWrapper for ResetSigmask {
17 fn pre_spawn(&mut self, command: &mut Command, _core: &CommandWrap) -> Result<()> {
18 unsafe {
19 command.pre_exec(|| {
20 let mut oldset = SigSet::empty();
21 let newset = SigSet::all();
22
23 #[cfg(feature = "tracing")]
24 trace!(unblocking=?newset, "resetting process sigmask");
25
26 sigprocmask(SigmaskHow::SIG_UNBLOCK, Some(&newset), Some(&mut oldset))?;
27
28 #[cfg(feature = "tracing")]
29 trace!(?oldset, "sigmask reset");
30 Ok(())
31 });
32 }
33 Ok(())
34 }
35}