mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-17 00:00:11 +02:00
This text historically was copied verbatim from rust-lang/rust's own README [1] with the intention of licensing projects the same as rustc's own license, namely a dual MIT/Apache-2.0 license. The clause about "various BSD-like licenses" isn't actually correct for almost all projects other than rust-lang/rust and the wording around "both" was slightly ambiguous. This commit updates the wording to match more precisely what's in the standard library [2], namely clarifying that there aren't any BSD-like licenses in this repository and that the source is licensable under either license, at your own discretion. [1]: https://github.com/rust-lang/rust/tree/f0fe716dbcbf2363ab8f929325d32a17e51039d0#license [2]: https://github.com/rust-lang/rust/blob/f0fe716dbcbf2363ab8f929325d32a17e51039d0/src/libstd/lib.rs#L5-L9
62 lines
1.5 KiB
Markdown
62 lines
1.5 KiB
Markdown
# tokio-signal
|
|
|
|
An implementation of Unix signal handling for Tokio
|
|
|
|
[](https://travis-ci.org/alexcrichton/tokio-signal)
|
|
|
|
[Documentation](https://docs.rs/tokio-signal)
|
|
|
|
## Usage
|
|
|
|
First, add this to your `Cargo.toml`:
|
|
|
|
```toml
|
|
[dependencies]
|
|
tokio-signal = "0.1"
|
|
```
|
|
|
|
Next you can use this in conjunction with the `tokio-core` and `futures` crates:
|
|
|
|
```rust,no_run
|
|
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
|
|
|
|
This project is licensed under either of
|
|
|
|
* Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
|
|
http://www.apache.org/licenses/LICENSE-2.0)
|
|
* MIT license ([LICENSE-MIT](LICENSE-MIT) or
|
|
http://opensource.org/licenses/MIT)
|
|
|
|
at your option.
|
|
|
|
### Contribution
|
|
|
|
Unless you explicitly state otherwise, any contribution intentionally submitted
|
|
for inclusion in Serde by you, as defined in the Apache-2.0 license, shall be
|
|
dual licensed as above, without any additional terms or conditions.
|