From 7dc0de7f9c494e842fe504149ba7abb1c8d3b90d Mon Sep 17 00:00:00 2001 From: Valera Cogut Date: Fri, 19 Oct 2018 15:59:44 +0300 Subject: [PATCH] Capture Ctrl+C in cli_wallet when not in daemon mode #1193 --- programs/cli_wallet/main.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/programs/cli_wallet/main.cpp b/programs/cli_wallet/main.cpp index 7a50d86cbe..88c027a20e 100644 --- a/programs/cli_wallet/main.cpp +++ b/programs/cli_wallet/main.cpp @@ -279,6 +279,17 @@ int main( int argc, char** argv ) { wallet_cli->register_api( wapi ); wallet_cli->start(); + + fc::set_signal_handler([](int signal) { + ilog( "Captured SIGINT not in daemon mode" ); + fclose(stdin); + }, SIGINT); + + fc::set_signal_handler([](int signal) { + ilog( "Captured SIGTERM not in daemon mode" ); + fclose(stdin); + }, SIGTERM); + wallet_cli->wait(); } else @@ -288,6 +299,10 @@ int main( int argc, char** argv ) exit_promise->set_value(signal); }, SIGINT); + fc::set_signal_handler([&exit_promise](int signal) { + exit_promise->set_value(signal); + }, SIGTERM); + ilog( "Entering Daemon Mode, ^C to exit" ); exit_promise->wait(); }