From efaa2eeb88056a5f88655f571d18d429a413f185 Mon Sep 17 00:00:00 2001 From: ailin-nemui Date: Fri, 23 Jun 2017 17:58:40 +0200 Subject: [PATCH] Merge pull request #721 from dequis/unexpected-exits term-terminfo: Avoid switching out of alt screen on unexpected exits (cherry picked from commit c56919768e1072985aab1377714ea5038417cd4d) --- src/fe-text/term-terminfo.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/fe-text/term-terminfo.c b/src/fe-text/term-terminfo.c index 3098a4e4..bca37efc 100644 --- a/src/fe-text/term-terminfo.c +++ b/src/fe-text/term-terminfo.c @@ -102,6 +102,17 @@ static GSourceFuncs sigcont_funcs = { .dispatch = sigcont_dispatch }; +static void term_atexit(void) +{ + if (!quitting && current_term && current_term->TI_rmcup) { + /* Unexpected exit, avoid switching out of alternate screen + to keep any on-screen errors (like noperl_die()'s) */ + current_term->TI_rmcup = NULL; + } + + term_deinit(); +} + int term_init(void) { struct sigaction act; @@ -140,7 +151,7 @@ int term_init(void) term_set_input_type(TERM_TYPE_8BIT); term_common_init(); - atexit(term_deinit); + atexit(term_atexit); return TRUE; }