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