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

impl SignalFd
pub fn new(mask: &SigSet) -> Result<SignalFd>
pub fn with_flags(mask: &SigSet, flags: SfdFlags) -> Result<SignalFd>
pub fn set_mask(&mut Self, mask: &SigSet) -> Result<()>
pub fn read_signal(&mut Self) -> Result<Option<siginfo>>

Trait Implementations

impl AsRawFd for SignalFd
fn as_raw_fd(&Self) -> RawFd
impl Debug for SignalFd
fn fmt(&Self, f: &mut $crate::fmt::Formatter<'_>) -> $crate::fmt::Result
impl Drop for SignalFd
fn drop(&mut Self)
impl Eq for SignalFd
impl Hash for SignalFd
fn hash<__H: $crate::hash::Hasher>(&Self, state: &mut __H) -> ()
impl Iterator for SignalFd
type Item = signalfd_siginfo
fn next(&mut Self) -> Option<Self::Item>
impl PartialEq<SignalFd> for SignalFd
fn eq(&Self, other: &SignalFd) -> bool
fn ne(&Self, other: &SignalFd) -> bool

Auto Trait Implementations

impl Send for SignalFd
impl Sync for SignalFd
impl Unpin for SignalFd
impl UnwindSafe for SignalFd

Blanket Implementations

impl<T> Any for T
where
    T: 'static + ?Sized,
fn type_id(&Self) -> TypeId
impl<T> Borrow<T> for T
where
    T: ?Sized,
fn borrow(&Self) -> &T
impl<T> BorrowMut<T> for T
where
    T: ?Sized,
fn borrow_mut(&mut Self) -> &mut T
impl<T> From<T> for T
fn from(t: T) -> T

Returns the argument unchanged.

impl<T, U> Into<U> for T
where
    U: From<T>,
fn into(Self) -> U

Calls U::from(self).

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

impl<I> IntoIterator for I
where
    I: Iterator,
type Item = <I as Iterator>::Item
type IntoIter = I
fn into_iter(Self) -> I
impl<T, U> TryFrom<U> for T
where
    U: Into<T>,
type Error = Infallible
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto<U> for T
where
    U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
fn try_into(Self) -> Result<U, <U as TryFrom<T>>::Error>