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 while not implementing Sigmask itself, which allows Concurrent to maintain internal consistency about signal masks while still providing this capability to its users.

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.

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".

Implementations on Foreign Types§

Source§

impl<S> BlockSignals for Rc<Concurrent<S>>
where S: Sigmask + BlockSignals,

Source§

async fn block_sigint_sigquit(&self) -> Result<Self::SavedMask, Errno>

Blocks SIGINT and SIGQUIT, returning the previous signal mask.

Between block_sigint_sigquit and restore_sigmask, the disposition of any signal must not be changed with the set_disposition method, or the restore_sigmask method will leave the signal mask in an inconsistent state. You must not call the select method either, since it does not take the effect of block_sigint_sigquit into account.

Source§

type SavedMask = <S as BlockSignals>::SavedMask

Source§

async fn restore_sigmask(&self, mask: Self::SavedMask) -> Result<(), Errno>

Implementors§