pub fn set_async_handler<F>(user_handler: F) -> Result<(), Error>Expand description
Register an asynchronous signal handler for Ctrl-C.
Signal handling will be spawned on the tokio runtime. Should only be called once, typically at the start of your program.
§Example
ctrlc_async::set_async_handler(async { println!("Hello world!"); }).expect("Error setting Ctrl-C handler");§Warning
On Unix, any existing SIGINT, SIGTERM and SIGHUP (if termination feature is enabled) or SA_SIGINFO
posix signal handlers will be overwritten. On Windows, multiple handler routines are allowed,
but they are called on a last-registered, first-called basis until the signal is handled.
On Unix, signal dispositions and signal handlers are inherited by child processes created via
fork(2) on, but not by child processes created via execve(2).
Signal handlers are not inherited on Windows.
§Errors
Will return an error if another ctrlc::set_handler() handler exists or if a
system error occurred while setting the handler.
§Panics
Any panic in the handler will not be caught and will cause the signal handler thread to stop.