Skip to content

Commit

Permalink
Capture Ctrl+C in cli_wallet when not in daemon mode #1193
Browse files Browse the repository at this point in the history
  • Loading branch information
cogutvalera committed Oct 19, 2018
1 parent 05ea454 commit ad21932
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
2 changes: 1 addition & 1 deletion libraries/fc
18 changes: 8 additions & 10 deletions programs/cli_wallet/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,6 @@
# include <csignal>
#endif

#ifdef WIN32
#define QUIT_CURR_THREAD TerminateThread(pthread_self(), 0)
#else
#define QUIT_CURR_THREAD pthread_cancel(pthread_self())
#endif

using namespace graphene::app;
using namespace graphene::chain;
using namespace graphene::utilities;
Expand Down Expand Up @@ -286,16 +280,16 @@ int main( int argc, char** argv )
wallet_cli->register_api( wapi );
wallet_cli->start();

fc::set_signal_handler([&wapi, &wallet_file](int signal) {
fc::set_signal_handler([&wallet_cli, &wapi, &wallet_file](int signal) {
ilog( "Captured SIGINT not in daemon mode" );
wapi->save_wallet_file(wallet_file.generic_string());
QUIT_CURR_THREAD;
wallet_cli->quit_blocked_thread();
}, SIGINT);

fc::set_signal_handler([&wapi, &wallet_file](int signal) {
fc::set_signal_handler([&wallet_cli, &wapi, &wallet_file](int signal) {
ilog( "Captured SIGTERM not in daemon mode" );
wapi->save_wallet_file(wallet_file.generic_string());
QUIT_CURR_THREAD;
wallet_cli->quit_blocked_thread();
}, SIGTERM);

wallet_cli->wait();
Expand All @@ -307,6 +301,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();
}
Expand Down

0 comments on commit ad21932

Please sign in to comment.