[][src]Struct nix::sys::signalfd::SignalFd

pub struct SignalFd(_);

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
}

Methods

impl SignalFd[src]

pub fn new(mask: &SigSet) -> Result<SignalFd>[src]

pub fn with_flags(mask: &SigSet, flags: SfdFlags) -> Result<SignalFd>[src]

pub fn set_mask(&mut self, mask: &SigSet) -> Result<()>[src]

pub fn read_signal(&mut self) -> Result<Option<siginfo>>[src]

Trait Implementations

impl AsRawFd for SignalFd[src]

impl Clone for SignalFd[src]

impl Debug for SignalFd[src]

impl Drop for SignalFd[src]

impl Eq for SignalFd[src]

impl Hash for SignalFd[src]

impl Iterator for SignalFd[src]

type Item = siginfo

The type of the elements being iterated over.

impl PartialEq<SignalFd> for SignalFd[src]

impl StructuralEq for SignalFd[src]

impl StructuralPartialEq for SignalFd[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.