Skip to content

Commit

Permalink
Properly exit when receiving SIGINT/SIGTERM/SIGHUP (#377)
Browse files Browse the repository at this point in the history
  • Loading branch information
reese authored Nov 27, 2022
1 parent 0db5183 commit 3e39251
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
23 changes: 23 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ edition = "2018"

[dependencies]
clap = { version = "3.2.16", features = ["derive"] }
ctrlc = { version = "3.2", features = ["termination"] }
dirs = "3.0.2"
filetime = "0.2.14"
glob = "0.3"
Expand Down
6 changes: 6 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,12 @@ fn puts_stdout(input: &String) {
}

fn main() {
ctrlc::set_handler(move || {
eprintln!("`rubyfmt` process was terminated. Exiting...");
exit(1);
})
.expect("Error setting Ctrl-C handler");

updates::begin_checking_for_updates();

let opts = get_command_line_options();
Expand Down

0 comments on commit 3e39251

Please sign in to comment.