Windows signal trapping for rust
Clone or download
Latest commit b345e80 Jan 29, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples Version 0.3.0 Jan 29, 2019
src Version 0.3.0 Jan 29, 2019
.gitignore Initial commit Jan 18, 2019
Cargo.toml Version 0.3.0 Jan 29, 2019
README.md Version 0.2.1 Jan 27, 2019

README.md

wintrap-rs

The wintrap crate allows a Windows process to trap one or more abstracted "signals", running an asynchronous callback function whenever they are caught while active.

Examples

wintrap::trap(vec![wintrap::Signal::CtrlC, wintrap::Signal::CloseWindow], |signal| {
    // handle signal here
    println!("Caught a signal: {:?}", signal);
}, || {
    // do work
    println!("Doing work");
}).unwrap();

Caveats

Please note that it is not possible to correctly trap Ctrl-C signals when running programs via cargo run. You will have to run them directly via the target directory after building.