summaryrefslogtreecommitdiff
path: root/src/fe-text
diff options
context:
space:
mode:
authordequis <dx@dxzone.com.ar>2017-06-17 13:47:13 -0300
committerdequis <dx@dxzone.com.ar>2017-06-17 13:47:13 -0300
commit4b1c60b2ecb030550716647bffb0f9dd7e97c31a (patch)
tree60f1096ec146fac6bf5ed96a8bfab391163cf16d /src/fe-text
parent9d3cfe1069b5cfaf0efb972e36695b781ecf93de (diff)
downloadirssi-4b1c60b2ecb030550716647bffb0f9dd7e97c31a.zip
term-terminfo: Avoid switching out of alt screen on unexpected exits
Perl sucks and kills the whole process when there's a version mismatch in Perl_xs_handshake(). Our atexit handler catches the exit and deinitializes the terminal, removing the error. This commit uses the 'quitting' global variable which is set when irssi is voluntarily quitting, and avoids sending TI_rmcup, which restores the original screen and makes the error invisible.
Diffstat (limited to 'src/fe-text')
-rw-r--r--src/fe-text/term-terminfo.c13
1 files changed, 12 insertions, 1 deletions
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;
}