Struct SignalFd

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

# use nix::sys::signalfd::*;
// 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

fn new(mask: &SigSet) -> Result<SignalFd>
fn with_flags(mask: &SigSet, flags: SfdFlags) -> Result<SignalFd>
fn set_mask(self: &Self, mask: &SigSet) -> Result<()>
fn read_signal(self: &Self) -> Result<Option<siginfo>>
unsafe fn from_owned_fd(fd: OwnedFd) -> Self

Constructs a SignalFd wrapping an existing OwnedFd.

Safety

OwnedFd is a valid SignalFd.

impl AsFd for SignalFd

fn as_fd(self: &Self) -> BorrowedFd<'_>

impl AsRawFd for SignalFd

fn as_raw_fd(self: &Self) -> RawFd

impl Debug for SignalFd

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

impl Freeze for SignalFd

impl Iterator for SignalFd

fn next(self: &mut Self) -> Option<<Self as >::Item>

impl RefUnwindSafe for SignalFd

impl Send for SignalFd

impl Sync for SignalFd

impl Unpin for SignalFd

impl UnsafeUnpin for SignalFd

impl UnwindSafe for SignalFd

impl<I> IntoIterator for SignalFd

fn into_iter(self: Self) -> I

impl<T> Any for SignalFd

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for SignalFd

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for SignalFd

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

impl<T> From for SignalFd

fn from(t: T) -> T

Returns the argument unchanged.

impl<T, U> Into for SignalFd

fn into(self: Self) -> U

Calls U::from(self).

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

impl<T, U> TryFrom for SignalFd

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

impl<T, U> TryInto for SignalFd

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