How to replace default SIGINT handler when using sigaction?

I played with sigactionin the box nix-rustto try to process the SIGINT signal in my program and do nothing instead. Although I was able to process the signal using:

let sig_action = signal::SigAction::new(
    handle_signal,
    signal::SockFlag::empty(),
    signal::SigSet::empty()
);
unsafe { signal::sigaction(signal::SIGINT, &sig_action); }

It seems that no matter what I do in the function handle_signal, when it finishes, SIGINT is still being processed and the program exits. My handler does not replace the default functionality; rather, it happens before that. What should the function have done instead to prevent the interruption from shutting down the program?

+4
source share
1 answer

cargo run ? , , SIGINT, . , , .

+1

All Articles