Quellcodebibliothek Statistik Leitseite products/sources/formale Sprachen/C/Firefox/third_party/rust/tokio/tests/   (Browser von der Mozilla Stiftung Version 136.0.1©)  Datei vom 10.2.2025 mit Größe 640 B image not shown  

Quelle  signal_ctrl_c.rs   Sprache: unbekannt

 
#![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
#![cfg(unix)]

mod support {
    pub mod signal;
}
use support::signal::send_signal;

use tokio::signal;
use tokio::sync::oneshot;
use tokio_test::assert_ok;

#[tokio::test]
async fn ctrl_c() {
    let ctrl_c = signal::ctrl_c();

    let (fire, wait) = oneshot::channel();

    // NB: simulate a signal coming in by exercising our signal handler
    // to avoid complications with sending SIGINT to the test process
    tokio::spawn(async {
        wait.await.expect("wait failed");
        send_signal(libc::SIGINT);
    });

    let _ = fire.send(());

    assert_ok!(ctrl_c.await);
}

[ Dauer der Verarbeitung: 0.15 Sekunden  (vorverarbeitet)  ]