Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.

Commit

Permalink
Clone exit signal while intentionally shadowing
Browse files Browse the repository at this point in the history
  • Loading branch information
ryoqun committed Apr 25, 2023
1 parent 4d480a2 commit 9de98b2
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions tokens/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@ fn main() -> Result<(), Box<dyn Error>> {
let client = RpcClient::new(json_rpc_url);

let exit = Arc::new(AtomicBool::default());
let exit_for_ctrlc_handler = exit.clone();
// Initialize CTRL-C handler to ensure db changes are written before exit.
ctrlc::set_handler(move || {
exit_for_ctrlc_handler.store(true, Ordering::SeqCst);
ctrlc::set_handler({
let exit = exit.clone();
move || {
exit.store(true, Ordering::SeqCst);
}
})
.expect("Error setting Ctrl-C handler");

Expand Down

0 comments on commit 9de98b2

Please sign in to comment.