pub struct ExitHandler { /* private fields */ }Implementations§
Source§impl ExitHandler
impl ExitHandler
Sourcepub fn listen() -> &'static Arc<ExitHandler>
pub fn listen() -> &'static Arc<ExitHandler>
Waits for SIGINT using [tokio::signal::ctrl_c], and exits the process with exit code 0
after running any futures scheduled with ExitHandler::on_exit.
As this uses global process signals, this must only be called once, and will panic if called
multiple times. Use this when you own the process (e.g. turbopack-cli).
If you don’t own the process (e.g. you’re called as a library, such as in next-swc), use
ExitHandler::new_receiver instead.
This may listen for other signals, like SIGTERM or SIGPIPE in the future.
Sourcepub fn new_receiver() -> (Arc<ExitHandler>, ExitReceiver)
pub fn new_receiver() -> (Arc<ExitHandler>, ExitReceiver)
Creates an ExitHandler that can be manually controlled with an ExitReceiver.
This does not actually exit the process or listen for any signals. If you’d like that
behavior, use ExitHandler::listen.
Because this API has no global side-effects and can be called many times within the same
process, it is possible to use it to provide a mock ExitHandler inside unit tests.