Function nc::call::signal

source ·
pub unsafe fn signal(
    sig: i32,
    handler: sighandler_t
) -> Result<sighandler_t, Errno>
Expand description

Signal handling.

Deprecated. Use sigaction() instead.

§Example

fn handle_sigterm(signum: i32) {
    assert_eq!(signum, nc::SIGTERM);
}
// let ret = nc::signal(nc::SIGTERM, nc::SIG_IGN);
let ret = unsafe { nc::signal(nc::SIGTERM, handle_sigterm as nc::sighandler_t) };
assert!(ret.is_ok());
let ret = unsafe { nc::kill(nc::getpid(), nc::SIGTERM) };
assert!(ret.is_ok());