Skip to content

Commit

Permalink
signal: add example with background listener (tokio-rs#4171)
Browse files Browse the repository at this point in the history
  • Loading branch information
vanillajonathan authored and Oliver Giersch committed Oct 28, 2021
1 parent d5b42be commit 4dd1afe
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tokio/src/signal/ctrl_c.rs
Expand Up @@ -47,6 +47,15 @@ use std::io;
/// println!("received ctrl-c event");
/// }
/// ```
///
/// Listen in the background:
///
/// ```rust,no_run
/// tokio::spawn(async move {
/// tokio::signal::ctrl_c().await.unwrap();
/// // Your handler here
/// });
/// ```
pub async fn ctrl_c() -> io::Result<()> {
os_impl::ctrl_c()?.recv().await;
Ok(())
Expand Down

0 comments on commit 4dd1afe

Please sign in to comment.