fs_cli: refactor allow_ctl_c handling

This way we don't have to lie about whether we're connected to achieve
our intended result.
This commit is contained in:
Travis Cross 2011-09-22 05:23:24 +00:00
parent 4ae6cce43c
commit ee94dac7cb

View File

@ -61,6 +61,7 @@ typedef struct {
static int warn_stop = 0;
static int connected = 0;
static int allow_ctl_c = 0;
static char prompt_str[512] = "";
static cli_profile_t profiles[128] = {{{0}}};
static cli_profile_t internal_profile = {{ 0 }};
@ -480,7 +481,7 @@ static BOOL console_readConsole(HANDLE conIn, char *buf, int len, int *pRed, int
static void handle_SIGINT(int sig)
{
if (!connected) {
if (!connected || allow_ctl_c) {
fprintf(stdout, "Interrupted.\n");
exit(1);
}
@ -979,7 +980,6 @@ int main(int argc, char *argv[])
int temp_log = -1;
int argv_error = 0;
int argv_exec = 0;
int ctl_c = 0;
char argv_command[1024] = "";
char argv_loglevel[128] = "";
int argv_quiet = 0;
@ -1048,7 +1048,7 @@ int main(int argc, char *argv[])
argv_quiet = 1;
break;
case 'i':
ctl_c = 1;
allow_ctl_c = 1;
break;
case 'r':
loops += 120;
@ -1126,9 +1126,7 @@ int main(int argc, char *argv[])
esl_log(ESL_LOG_INFO, "Retrying\n");
}
} else {
if (!ctl_c) {
connected = 1;
}
connected = 1;
if (temp_log < 0 ) {
esl_global_set_default_logger(profile->debug);
} else {