Name | Date | Size | #Lines | LOC | ||
---|---|---|---|---|---|---|
.. | 03-May-2022 | - | ||||
examples/ | H | 03-May-2022 | - | 50 | 35 | |
src/ | H | 03-May-2022 | - | 727 | 439 | |
.cargo-checksum.json | H A D | 03-May-2022 | 89 | 1 | 1 | |
.cargo_vcs_info.json | H A D | 01-Jan-1970 | 74 | 6 | 5 | |
.gitignore | H A D | 01-Jan-1970 | 18 | 3 | 2 | |
Cargo.lock | H A D | 01-Jan-1970 | 2.2 KiB | 84 | 73 | |
Cargo.toml | H A D | 01-Jan-1970 | 1.3 KiB | 43 | 39 | |
Cargo.toml.orig-cargo | H A D | 01-Jan-1970 | 861 | 32 | 26 | |
LICENSE-APACHE | H A D | 01-Jan-1970 | 10.6 KiB | 202 | 169 | |
LICENSE-MIT | H A D | 01-Jan-1970 | 1,023 | 24 | 21 | |
README.md | H A D | 01-Jan-1970 | 1.5 KiB | 48 | 35 |
README.md
1# CtrlC 2[![Build Status](https://travis-ci.org/Detegr/rust-ctrlc.svg?branch=master)](https://travis-ci.org/Detegr/rust-ctrlc) 3[![Build status](https://ci.appveyor.com/api/projects/status/kwg1uu2w2aqn9ta9/branch/master?svg=true)](https://ci.appveyor.com/project/Detegr/rust-ctrlc/branch/master) 4 5A simple easy to use wrapper around Ctrl-C signal. 6 7[Documentation](http://detegr.github.io/doc/ctrlc/) 8 9## Example usage 10```rust 11use std::sync::mpsc::channel; 12use ctrlc; 13 14fn main() { 15 let (tx, rx) = channel(); 16 17 ctrlc::set_handler(move || tx.send(()).expect("Could not send signal on channel.")) 18 .expect("Error setting Ctrl-C handler"); 19 20 println!("Waiting for Ctrl-C..."); 21 rx.recv().expect("Could not receive from channel."); 22 println!("Got it! Exiting..."); 23} 24``` 25 26#### Try the example yourself 27`cargo build --examples && target/debug/examples/readme_example` 28 29## Handling SIGTERM and SIGHUP 30Add CtrlC to Cargo.toml using `termination` feature and CtrlC will handle SIGINT, SIGTERM and SIGHUP. 31``` 32[dependencies] 33ctrlc = { version = "3.0", features = ["termination"] } 34``` 35 36## License 37 38Licensed under either of 39 * Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) 40 * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) 41at your option. 42 43### Contribution 44 45Unless you explicitly state otherwise, any contribution intentionally submitted 46for inclusion in the work by you shall be dual licensed as above, without any 47additional terms or conditions. 48