Skip to main content

BlockSignals

Trait BlockSignals 

Source
pub trait BlockSignals: Signals {
    type SavedMask;

    // Required methods
    fn block_sigint_sigquit(
        &self,
    ) -> impl Future<Output = Result<Self::SavedMask, Errno>> + use<'_, Self>;
    fn restore_sigmask(
        &self,
        mask: Self::SavedMask,
    ) -> impl Future<Output = Result<(), Errno>> + use<'_, Self>;
}
Expand description

Trait to temporarily block the SIGINT and SIGQUIT signals

This trait represents the capability required by Config::start to temporarily block SIGINT and SIGQUIT while starting a subshell. Any type that implements Sigmask automatically implements this trait. Additionally, Concurrent implements this trait by delegating to the inner system.

This trait defines a higher-level interface to temporarily modify the signal mask. Typically, implementors of this trait will internally depend on Sigmask to perform the actual signal mask modification, but the details are abstracted away. In particular, using this trait as the public capability leaves room for types such as Concurrent to stop exposing Sigmask directly in a future release while still providing the behavior required by callers.

Required Associated Types§

Required Methods§

Source

fn block_sigint_sigquit( &self, ) -> impl Future<Output = Result<Self::SavedMask, Errno>> + use<'_, Self>

Blocks SIGINT and SIGQUIT, returning the previous signal mask.

After this function returns successfully, one of the following must be performed:

  • Call restore_sigmask with the returned mask to restore the original signal mask,
  • Call SignalSystem::set_disposition to re-set the disposition of SIGINT and SIGQUIT, which installs a new signal mask,
  • Exit the process without restoring the signal mask.
Source

fn restore_sigmask( &self, mask: Self::SavedMask, ) -> impl Future<Output = Result<(), Errno>> + use<'_, Self>

Restores the signal mask.

This function restores the signal mask to the state represented by mask, which should be a value returned by a previous call to block_sigint_sigquit.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<S> BlockSignals for S
where S: Sigmask + ?Sized,