Use Control - C To Stop A Rust Process That's Using watchexec
I'm using the watchexec we Rust crate to run my site generate process every time a file changes. It's the same create that powers cargo watch cw .
I ran into a problem with it where once I started it it CTRL C wouldn't stop it because it captured the signal. That makes sense, but meant the only way I could stop the process was to kill the terminal window.
This is what I came up with to catch the Interrupt signal that's sent by control - c in watchexec and tell it to stop itself via an ` Outcome : : Exit [TODO: Code shorthand span ] signal :
use Error;
use Result;
use Action;
use Outcome;
use InitConfig;
use RuntimeConfig;
use Watchexec;
use Signal;
async
That's relatively concise, but I expect there's ways to tighten it up. In the mean time, it's doing what I need.
Footnotes And References
- •
- •
- •
- •