2017-06-19 09:01:42 -05:00
2017-06-07 12:29:31 -07:00
2017-01-26 20:45:19 +01:00
2016-09-06 23:00:17 -07:00
2017-06-07 12:29:31 -07:00
2017-03-15 10:36:37 -07:00
2016-09-07 00:04:49 -07:00
2016-09-07 00:04:49 -07:00
2017-06-19 14:38:02 +02: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-core and futures crates:

extern crate futures;
extern crate tokio_core;
extern crate tokio_signal;

use tokio_core::reactor::Core;
use futures::{Future, Stream};

fn main() {
    let mut core = Core::new().unwrap();
    let handle = core.handle();

    // 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(&handle).flatten_stream();

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

    core.run(prog).unwrap();
}

License

tokio-signal is primarily distributed under the terms of both the MIT license and the Apache License (Version 2.0), with portions covered by various BSD-like licenses.

See LICENSE-APACHE, and LICENSE-MIT for details.

S
Description
A runtime for writing reliable asynchronous applications with Rust. Provides I/O, networking, scheduling, timers, ...
Readme MIT
62 MiB
Languages
Rust 100%