Struct SignalFd
pub struct SignalFd(/* private field */);
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, mask: &SigSet) -> Result<()>fn read_signal(&self) -> Result<Option<siginfo>>unsafe fn from_owned_fd(fd: OwnedFd) -> SelfConstructs a
SignalFdwrapping an existingOwnedFd.Safety
OwnedFdis a validSignalFd.
Trait Implementations
impl AsFd for SignalFd
fn as_fd(&self) -> BorrowedFd<'_>
impl AsRawFd for SignalFd
fn as_raw_fd(&self) -> RawFd
impl Debug for SignalFd
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl Iterator for SignalFd
type Item = signalfd_siginfo;fn next(&mut self) -> Option<Self::Item>