Struct SignalHandlerGuard

Source
pub struct SignalHandlerGuard<'a> { /* private fields */ }
Expand description

This is the primary interface to the crate. When this guard is constructed a new signal handler for one or more signals is pushed onto the top of the stack.

When it is dropped, the signal handler will be removed from the stack. Signal handlers can be removed at any time, it need not be in reverse order, although that would typically be the case.

Implementations§

Source§

impl<'a> SignalHandlerGuard<'a>

Source

pub unsafe fn new_unsafe( signums: &'a [c_int], handler: Arc<dyn Handler>, ) -> Self

Add a new signal handler.

§Safety

The handler function must be async-signal-safe, which places severe restrictions on what the function may do.

A non-exhaustive list of things that are not allowed:

  • Allocating or freeing memory.
  • Locking or unlocking mutexes or other kinds of concurrency primitive, with the exception of posting to a libc semaphore.
  • Calling a function which is not itself marked as async-signal-safe.
  • Performing any kind of blocking I/O.
Source

pub fn new<H: SafeHandler>(signums: &'a [c_int], handler: H) -> Self

Safely construct a signal guard from a function known statically to be async-signal-safe.

Source

pub fn forget(self)

Forget this signal guard: the handler will remain attached for the lifetime of the program.

Trait Implementations§

Source§

impl<'a> Debug for SignalHandlerGuard<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> Drop for SignalHandlerGuard<'a>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for SignalHandlerGuard<'a>

§

impl<'a> !RefUnwindSafe for SignalHandlerGuard<'a>

§

impl<'a> Send for SignalHandlerGuard<'a>

§

impl<'a> Sync for SignalHandlerGuard<'a>

§

impl<'a> Unpin for SignalHandlerGuard<'a>

§

impl<'a> !UnwindSafe for SignalHandlerGuard<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.