Let CLI be able to restart

This commit is contained in:
abitmore 2019-05-09 13:50:53 -04:00
parent 9605f4826b
commit b562d81a65

View file

@ -105,20 +105,12 @@ void cli::run()
} }
catch ( const fc::eof_exception& e ) catch ( const fc::eof_exception& e )
{ {
if( _getline_thread ) _getline_thread = nullptr;
{
_getline_thread->quit();
_getline_thread = nullptr;
}
break; break;
} }
catch ( const fc::canceled_exception& e ) catch ( const fc::canceled_exception& e )
{ {
if( _getline_thread ) _getline_thread = nullptr;
{
_getline_thread->quit();
_getline_thread = nullptr;
}
break; break;
} }
@ -142,11 +134,7 @@ void cli::run()
{ {
if (e.code() == fc::canceled_exception_code) if (e.code() == fc::canceled_exception_code)
{ {
if( _getline_thread ) _getline_thread = nullptr;
{
_getline_thread->quit();
_getline_thread = nullptr;
}
break; break;
} }
std::cout << e.to_detail_string() << "\n"; std::cout << e.to_detail_string() << "\n";
@ -257,6 +245,10 @@ static int cli_check_secret(const char *source)
return 0; return 0;
} }
/***
* Indicates whether CLI is quitting after got a SIGINT signal.
* In order to be used by editline which is C-style, this is a global variable.
*/
static int cli_quitting = false; static int cli_quitting = false;
/** /**
@ -292,6 +284,8 @@ void cli::start()
static fc::thread getline_thread("getline"); static fc::thread getline_thread("getline");
_getline_thread = &getline_thread; _getline_thread = &getline_thread;
cli_quitting = false;
cli_commands() = get_method_names(0); cli_commands() = get_method_names(0);
#endif #endif