diff --git a/tcltk/tclmagic.c b/tcltk/tclmagic.c index bc454a90..ae63ddb0 100644 --- a/tcltk/tclmagic.c +++ b/tcltk/tclmagic.c @@ -634,7 +634,7 @@ _magic_initialize(ClientData clientData, return TCL_OK; magicfatal: - TxResetTerminal(); + TxResetTerminal(FALSE); Tcl_SetResult(interp, "Magic initialization encountered a fatal error.", NULL); return TCL_ERROR; } @@ -780,7 +780,7 @@ _magic_startup(ClientData clientData, NULL); } - TxResetTerminal(); + TxResetTerminal(FALSE); if (TxTkConsole) { diff --git a/textio/textio.h b/textio/textio.h index b7c6c1c2..edd019ac 100644 --- a/textio/textio.h +++ b/textio/textio.h @@ -89,7 +89,7 @@ extern void TxReprint(); /* terminal-state procedures */ extern void TxSetTerminal(); -extern void TxResetTerminal(); +extern void TxResetTerminal(bool force); extern char TxEOFChar; /* The current EOF character */ extern char TxInterruptChar; /* The current interrupt character */ diff --git a/textio/txInput.c b/textio/txInput.c index 3a6ef16d..20b527ac 100644 --- a/textio/txInput.c +++ b/textio/txInput.c @@ -1004,7 +1004,7 @@ TxGetLineWPrompt(dest, maxChars, prompt, prefix) txReprint1 = NULL; #else _rl_prefix = prefix; - TxResetTerminal (); + TxResetTerminal (FALSE); if (prompt != NULL) { res = readline (prompt); @@ -1427,6 +1427,9 @@ TxSetTerminal() * * Returns the terminal to the way it was when Magic started up. * + * 'force' maybe set for atexit() restoration, when the console + * input handler is no longer in effect. Also crash handling, SIGSTOP. + * * Results: * none. * @@ -1436,13 +1439,12 @@ TxSetTerminal() */ void -TxResetTerminal() +TxResetTerminal(bool force) { - #ifdef MAGIC_WRAPPER /* If using Tk console, don't mess with the terminal settings; */ /* Otherwise, this prevents running magic in the terminal background. */ - if (TxTkConsole) return; + if (TxTkConsole && !force) return; #endif if (TxStdinIsatty && haveCloseState) txSetTermState(&closeTermState); diff --git a/utils/main.c b/utils/main.c index a3f218a7..6f57447e 100644 --- a/utils/main.c +++ b/utils/main.c @@ -195,7 +195,7 @@ MainExit(errNum) DBRemoveBackup(); TxFlush(); - TxResetTerminal(); + TxResetTerminal(FALSE); /* set also atexit() handler */ #ifdef MAGIC_WRAPPER diff --git a/utils/signals.c b/utils/signals.c index 9250d6ea..e334a47e 100644 --- a/utils/signals.c +++ b/utils/signals.c @@ -204,7 +204,7 @@ sigRetVal sigOnStop(int signo) { /* fix things up */ - TxResetTerminal(); + TxResetTerminal(TRUE); GrStop(); /* restore the default action and resend the signal */ @@ -565,7 +565,7 @@ sigCrash(signum) strcpy(AbortMessage, msg); AbortFatal = TRUE; niceabort(); - TxResetTerminal(); + TxResetTerminal(TRUE); } #else if (magicNumber == 1239987) { @@ -585,7 +585,7 @@ sigCrash(signum) strcpy(AbortMessage, msg); AbortFatal = TRUE; niceabort(); - TxResetTerminal(); + TxResetTerminal(TRUE); } #endif