Index: main/asterisk.c =================================================================== --- main/asterisk.c (revision 266338) +++ main/asterisk.c (working copy) @@ -2086,6 +2086,9 @@ #endif /* ! LOW_MEMORY */ }; +static struct ast_str *prompt = NULL; +static struct ast_str *overwrite_prompt = NULL; + static int ast_el_read_char(EditLine *editline, char *cp) { int num_read = 0; @@ -2139,15 +2142,22 @@ fprintf(stderr, "Reconnect succeeded after %.3f seconds\n", 1.0 / reconnects_per_second * tries); printf("%s", term_quit()); WELCOME_MESSAGE; - if (!ast_opt_mute) + if (!ast_opt_mute) { fdsend(ast_consock, "logger mute silent"); - else + } else { printf("log and verbose output currently muted ('logger mute' to unmute)\n"); + } break; - } else + } else if (sig_flags.need_quit == 1) { + tries = -1; + break; + } else { usleep(1000000 / reconnects_per_second); + } } - if (tries >= 30 * reconnects_per_second) { + if (tries < 0) { + quit_handler(0, 0, 0, 0); + } else if (tries >= 30 * reconnects_per_second) { fprintf(stderr, "Failed to reconnect for 30 seconds. Quitting.\n"); quit_handler(0, 0, 0, 0); } @@ -2167,7 +2177,7 @@ /* Write over the CLI prompt */ if (!ast_opt_exec && !lastpos) { - if (write(STDOUT_FILENO, "\r", 1) < 0) { + if (write(STDOUT_FILENO, prompt ? ast_str_buffer(overwrite_prompt) : "\r", prompt ? ast_str_strlen(overwrite_prompt) : 1) < 0) { } } if (write(STDOUT_FILENO, buf, res) < 0) { @@ -2184,8 +2194,6 @@ return (0); } -static struct ast_str *prompt = NULL; - static char *cli_prompt(EditLine *editline) { char tmp[100]; @@ -2198,6 +2206,7 @@ if (prompt == NULL) { prompt = ast_str_create(100); + overwrite_prompt = ast_str_create(100); } else if (!cli_prompt_changes) { return ast_str_buffer(prompt); } else { @@ -2309,8 +2318,9 @@ } else { ast_str_set(&prompt, 0, "%s", ASTERISK_PROMPT); } + ast_str_set(&overwrite_prompt, 0, "%*s\r", ast_str_strlen(prompt), " "); - return ast_str_buffer(prompt); + return ast_str_buffer(prompt); } static char **ast_el_strtoarr(char *buf)