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

..03-May-2022-

examples/H03-May-2022-5035

src/H03-May-2022-727439

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

.cargo_vcs_info.jsonH A D01-Jan-197074 65

.gitignoreH A D01-Jan-197018 32

Cargo.lockH A D01-Jan-19702.2 KiB8473

Cargo.tomlH A D01-Jan-19701.3 KiB4339

Cargo.toml.orig-cargoH A D01-Jan-1970861 3226

LICENSE-APACHEH A D01-Jan-197010.6 KiB202169

LICENSE-MITH A D01-Jan-19701,023 2421

README.mdH A D01-Jan-19701.5 KiB4835

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