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) -> SigActionCreates a new action.
The
SA_SIGINFObit in theflagsargument is ignored (it will be set only ifhandleris theSigActionvariant).maskspecifies other signals to block during execution of the signal-catching function.fn flags(&self) -> SaFlagsReturns the flags set on the action.
fn mask(&self) -> SigSetReturns the set of signals that are blocked during execution of the action's signal-catching function.
fn handler(&self) -> SigHandlerReturns 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