Files
tokio/tokio-signal/README.md
T

46 lines
1.0 KiB
Markdown
Raw Normal View History

2016-09-06 23:00:17 -07:00
# tokio-signal
2019-03-22 13:55:48 -07:00
Unix signal handling for Tokio.
2016-09-06 23:00:17 -07:00
2019-03-22 13:55:48 -07:00
[Documentation](https://docs.rs/tokio-signal/0.2.8/tokio_signal)
2016-09-06 23:00:17 -07:00
## Usage
First, add this to your `Cargo.toml`:
```toml
[dependencies]
2019-03-22 13:55:48 -07:00
tokio-signal = "0.2.8"
2016-09-06 23:00:17 -07:00
```
Next you can use this in conjunction with the `tokio` and `futures` crates:
2016-09-06 23:00:17 -07:00
2017-06-07 12:29:31 -07:00
```rust,no_run
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();
2017-06-07 12:29:31 -07:00
// 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)));
2017-06-07 12:29:31 -07:00
}
2016-09-06 23:00:17 -07:00
```
2019-03-22 13:55:48 -07:00
## License
2016-09-06 23:00:17 -07:00
2019-03-22 13:55:48 -07:00
This project is licensed under the [MIT license](./LICENSE).
2016-09-06 23:00:17 -07:00
### Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted
2018-09-07 09:56:40 +02:00
for inclusion in Tokio by you, shall be licensed as MIT, without any additional
terms or conditions.