pub fn set_rthandler(
rtsignal: u32,
handler: SignalHandler,
) -> Result<(), SetHandlerError>Available on Unix and crate feature
signals only.Expand description
Installs the specified handler for the specified real-time signal, using the default values for the flags.
See HandlerOptions builder if you’d like to customize the flags.
§Example
use interprocess::os::unix::signal::{self, SignalHandler};
let handler = unsafe {
// Since signal handlers are restricted to a specific set of C functions, creating a
// handler from an arbitrary function is unsafe because it might call a function
// outside the list, and there's no real way to know that at compile time with the
// current version of Rust. Since we're only using the write() system call here, this
// is safe.
SignalHandler::from_fn(|| {
println!("You sent a real-time signal!");
})
};
// Install our handler for the real-time signal 0.
signal::set_rthandler(0, handler)?;