No description
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2018-06-14 10:10:41 +02:00
examples Remove test that were accidentally included in the ctrl-c example 2018-05-05 20:33:51 +02:00
src WIP redox support 2018-06-14 10:10:41 +02:00
tests refactor: Prefer the implicit handle passing used by tokio 2018-05-05 20:20:02 +02:00
.gitignore Initial commit 2016-09-06 23:00:17 -07:00
.travis.yml Tweak travis config 2017-11-30 05:36:54 -08:00
appveyor.yml Add an appveyor build file 2018-05-06 21:13:57 +02:00
Cargo.toml WIP redox support 2018-06-14 10:10:41 +02:00
CHANGELOG.md Version 0.2 2018-05-07 20:34:47 +02:00
LICENSE-APACHE Add licenses 2016-09-07 00:04:49 -07:00
LICENSE-MIT Add licenses 2016-09-07 00:04:49 -07:00
README.md Fix typo in README.md 2018-05-24 17:01:48 -07:00

tokio-signal

An implementation of Unix signal handling for Tokio

Build Status

Documentation

Usage

First, add this to your Cargo.toml:

[dependencies]
tokio-signal = "0.1"

Next you can use this in conjunction with the tokio and futures crates:

extern crate futures;
extern crate tokio;
extern crate tokio_signal;

use futures::{Future, Stream};

fn main() {

    // Create an infinite stream of "Ctrl+C" notifications. Each item received
    // on this stream may represent multiple ctrl-c signals.
    let ctrl_c = tokio_signal::ctrl_c().flatten_stream();

    // Process each ctrl-c as it comes in
    let prog = ctrl_c.for_each(|()| {
        println!("ctrl-c received!");
        Ok(())
    });

    tokio::run(prog.map_err(|err| panic!("{}", err)));
}

License

This project is licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in tokio-signal by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.