Struct nix::sys::signalfd::SignalFd
pub struct SignalFd(_);
Documentation
A helper struct for creating, reading and closing a signalfd
instance.
Important: please read the module level documentation about signal discarding before using this struct!
Examples
// Set the thread to block the SIGUSR1 signal, otherwise the default handler will be used
let mut mask = SigSet::empty();
mask.add(signal::SIGUSR1);
mask.thread_block().unwrap();
// Signals are queued up on the file descriptor
let mut sfd = SignalFd::with_flags(&mask, SfdFlags::SFD_NONBLOCK).unwrap();
match sfd.read_signal() {
// we caught a signal
Ok(Some(sig)) => (),
// there were no signals waiting (only happens when the SFD_NONBLOCK flag is set,
// otherwise the read_signal call blocks)
Ok(None) => (),
Err(err) => (), // some error happend
}
Implementations
Trait Implementations
impl Debug for SignalFd
fn fmt(&Self, f: &mut $crate::fmt::Formatter<'_>) -> $crate::fmt::Result
impl Hash for SignalFd
fn hash<__H: $crate::hash::Hasher>(&Self, state: &mut __H) -> ()
impl StructuralEq for SignalFd
impl StructuralPartialEq for SignalFd
Auto Trait Implementations
impl RefUnwindSafe for SignalFd
impl UnwindSafe for SignalFd
Blanket Implementations
impl<T> BorrowMut<T> for T
where
T: ?Sized,
where
T: ?Sized,
fn borrow_mut(&mut Self) -> &mut T