diff --git a/tokens/src/commands.rs b/tokens/src/commands.rs index f7ce05aa47f976..74477048642b8b 100644 --- a/tokens/src/commands.rs +++ b/tokens/src/commands.rs @@ -833,7 +833,11 @@ fn check_payer_balances( Ok(()) } -pub fn process_balances(client: &RpcClient, args: &BalancesArgs) -> Result<(), Error> { +pub fn process_balances( + client: &RpcClient, + args: &BalancesArgs, + exit: Arc, +) -> Result<(), Error> { let allocations: Vec = read_allocations(&args.input_csv, None, false, args.spl_token_args.is_some())?; let allocations = merge_allocations(&allocations); @@ -855,6 +859,10 @@ pub fn process_balances(client: &RpcClient, args: &BalancesArgs) -> Result<(), E ); for allocation in &allocations { + if exit.load(Ordering::SeqCst) { + return Err(Error::ExitSignal); + } + if let Some(spl_token_args) = &args.spl_token_args { print_token_balances(client, allocation, spl_token_args)?; } else { diff --git a/tokens/src/main.rs b/tokens/src/main.rs index bbd8c0e435a8b6..1bf81b01fe486d 100644 --- a/tokens/src/main.rs +++ b/tokens/src/main.rs @@ -44,7 +44,7 @@ fn main() -> Result<(), Box> { } Command::Balances(mut args) => { spl_token::update_decimals(&client, &mut args.spl_token_args)?; - commands::process_balances(&client, &args)?; + commands::process_balances(&client, &args, exit)?; } Command::TransactionLog(args) => { commands::process_transaction_log(&args)?;