• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

examples/H03-May-2022-173107

src/H03-May-2022-1,010590

tests/H03-May-2022-259187

.cargo-checksum.jsonH A D03-May-202289 11

.cargo_vcs_info.jsonH A D05-Feb-202074 65

CHANGELOG.mdH A D04-Feb-20201.4 KiB5641

Cargo.lockH A D05-Feb-202014.3 KiB599539

Cargo.tomlH A D05-Feb-20201.6 KiB5647

Cargo.toml.orig-cargoH A D04-Feb-20201.1 KiB4438

LICENSEH A D04-Feb-20201 KiB2622

README.mdH A D04-Feb-20201.4 KiB5637

README.md

1# tokio-signal
2
3Unix signal handling for Tokio.
4
5> **Note:** This crate is **deprecated in tokio 0.2.x** and has been moved into
6> [`tokio::signal`] behind the `signal` [feature flag].
7
8[`tokio::signal`]: https://docs.rs/tokio/latest/tokio/signal/index.html
9[feature flag]: https://docs.rs/tokio/latest/tokio/index.html#feature-flags
10
11[Documentation](https://docs.rs/tokio-signal/0.2.8/tokio_signal)
12
13## Usage
14
15First, add this to your `Cargo.toml`:
16
17```toml
18[dependencies]
19tokio-signal = "0.2.8"
20```
21
22Next you can use this in conjunction with the `tokio` and `futures` crates:
23
24```rust,no_run
25extern crate futures;
26extern crate tokio;
27extern crate tokio_signal;
28
29use futures::{Future, Stream};
30
31fn main() {
32
33    // Create an infinite stream of "Ctrl+C" notifications. Each item received
34    // on this stream may represent multiple ctrl-c signals.
35    let ctrl_c = tokio_signal::ctrl_c().flatten_stream();
36
37    // Process each ctrl-c as it comes in
38    let prog = ctrl_c.for_each(|()| {
39        println!("ctrl-c received!");
40        Ok(())
41    });
42
43    tokio::run(prog.map_err(|err| panic!("{}", err)));
44}
45```
46
47## License
48
49This project is licensed under the [MIT license](./LICENSE).
50
51### Contribution
52
53Unless you explicitly state otherwise, any contribution intentionally submitted
54for inclusion in Tokio by you, shall be licensed as MIT, without any additional
55terms or conditions.
56