Currently, when Rust spawns a process on Unix, it always sets the signal mask to the empty set.
-
posix_spawn
: rust/process_unix.rs at 7fe2c4b00dfbc33643e1af4b293eb057306a8339 · rust-lang/rust · GitHub -
fork
/exec
: rust/process_unix.rs at 7fe2c4b00dfbc33643e1af4b293eb057306a8339 · rust-lang/rust · GitHub
It would be great if there were a way to configure this. My own use case is to block SIGTSTP and other signals, to work around a flaw in the definition of posix_spawn
. This is currently not possible to do with the Rust std::process::Command
APIs.
The general outline of the API I'd propose would be a new method on CommandExt
:
pub fn signal_mask(&mut self, mask: SignalMask) -> &mut Command;
pub struct SignalMask {
// impl as maybe a sigset_t
}
impl SignalMask {
pub fn empty() -> Self;
pub fn filled() -> Self;
pub fn add_signal(&mut self, signal: i32) -> &mut Self;
pub fn remove_signal(&mut self, signal: i32) -> &mut Self;
}