Index: main/asterisk.c =================================================================== --- main/asterisk.c (revision 320498) +++ main/asterisk.c (working copy) @@ -277,6 +277,7 @@ static char *_argv[256]; static int shuttingdown; static int restartnow; +static int console_gone = 0; static pthread_t consolethread = AST_PTHREADT_NULL; static pthread_t mon_sig_flags; static int canary_pid = 0; @@ -1653,6 +1654,7 @@ if (consolethread == AST_PTHREADT_NULL || consolethread == thisthread || mon_sig_flags == thisthread) { /* Only end if we are the consolethread or signal handler, otherwise there's a race with that thread. */ if (el != NULL) { + console_gone = 1; el_end(el); } if (el_hist != NULL) { @@ -2759,12 +2761,16 @@ ast_el_read_history(filename); for (;;) { - ebuf = (char *)el_gets(el, &num); + if (console_gone == 1) { + break; + } if (sig_flags.need_quit == 1) { break; } + ebuf = (char *)el_gets(el, &num); + if (!ebuf && write(1, "", 1) < 0) break; @@ -3855,6 +3861,10 @@ set_title(title); for (;;) { + if (console_gone) { + goto lostterm; + } + buf = (char *) el_gets(el, &num); if (!buf && write(1, "", 1) < 0)