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>
impl<'a> SignalHandlerGuard<'a>
Sourcepub unsafe fn new_unsafe(
signums: &'a [c_int],
handler: Arc<dyn Handler>,
) -> Self
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.
Sourcepub fn new<H: SafeHandler>(signums: &'a [c_int], handler: H) -> Self
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.
Trait Implementations§
Source§impl<'a> Debug for SignalHandlerGuard<'a>
impl<'a> Debug for SignalHandlerGuard<'a>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more