Skip to main content

on_ctrl_c

Function on_ctrl_c 

Source
pub fn on_ctrl_c() -> CancellationToken
Expand description

Install a first-Ctrl+C handler and return the cooperative cancellation token.

Must be called from within a Tokio runtime: a background task awaits the interrupt signal and cancels the returned token on the first Ctrl+C. Clone the token and hand it to spawned tasks, an rskit-worker handler, or an rskit-process call; holders observe is_cancelled() / cancelled() and wind down gracefully.