Struct SigAction

#[repr(transparent)]
pub struct SigAction { /* private fields */ }

Action to take on receipt of a signal.

SigAction wraps libc::sigaction, which defines the full signal disposition: the handler, flags controlling delivery behavior, and the set of signals to block while the handler runs. Construct one with SigAction::new and install it with sigaction.

Examples

Install a handler for SIGINT:

# use nix::sys::signal::{self, SaFlags, SigAction, SigHandler, SigSet, Signal};
extern "C" fn handle_sigint(signal: libc::c_int) {
    // handle signal
}

fn main() {
    let handler = SigHandler::Handler(handle_sigint);
    let action = SigAction::new(handler, SaFlags::empty(), SigSet::empty());
    unsafe { signal::sigaction(Signal::SIGINT, &action) }.unwrap();
}

Implementations

impl SigAction

fn new(handler: SigHandler, flags: SaFlags, mask: SigSet) -> SigAction

Creates a new action.

The SA_SIGINFO bit in the flags argument is ignored (it will be set only if handler is the SigAction variant). mask specifies other signals to block during execution of the signal-catching function.

fn flags(&self) -> SaFlags

Returns the flags set on the action.

fn mask(&self) -> SigSet

Returns the set of signals that are blocked during execution of the action's signal-catching function.

fn handler(&self) -> SigHandler

Returns the action's handler.

Trait Implementations

impl Clone for SigAction

fn clone(&self) -> Self

impl Copy for SigAction

impl Debug for SigAction

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

impl Eq for SigAction

impl Hash for SigAction

fn hash<__H: Hasher>(&self, state: &mut __H)

impl PartialEq for SigAction

fn eq(&self, other: &Self) -> bool

impl StructuralPartialEq for SigAction

Auto Trait Implementations

impl Freeze for SigAction

impl RefUnwindSafe for SigAction

impl Send for SigAction

impl Sync for SigAction

impl Unpin for SigAction

impl UnsafeUnpin for SigAction

impl UnwindSafe for SigAction

Blanket Implementations

impl<T> Any for SigAction where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for SigAction where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for SigAction where T: ?Sized,

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

impl<T> CloneToUninit for SigAction where T: Clone,

unsafe fn clone_to_uninit(&self, dest: *mut u8)

impl<T> From<T> for SigAction

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> ToOwned for SigAction where T: Clone,

type Owned = T;
fn to_owned(&self) -> T
fn clone_into(&self, target: &mut T)

impl<T, U> Into<U> for SigAction 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<T, U> TryFrom<U> for SigAction where U: Into<T>,

type Error = never;
fn try_from(value: U) -> Result<T, never>

impl<T, U> TryInto<U> for SigAction where U: TryFrom<T>,

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