]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
fs_cli: refactor allow_ctl_c handling
authorTravis Cross <tc@traviscross.com>
Thu, 22 Sep 2011 05:23:24 +0000 (05:23 +0000)
committerTravis Cross <tc@traviscross.com>
Fri, 23 Sep 2011 01:25:42 +0000 (01:25 +0000)
This way we don't have to lie about whether we're connected to achieve
our intended result.

libs/esl/fs_cli.c

index d3e766e0147beef7595438b9392f20ec0af5060f..4e6b20a2b2ddcc622c6ebf050aebe3976967b166 100644 (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 {