From 0a8770ac7d382df8976b2448fccc6cfe434cd4d1 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Sun, 12 Apr 2026 21:47:58 +0200 Subject: GTK: SIGTERM/SIGHUP always terminates the program and dumps recovery files * SIGTERM used to insert the ^KCLOSE key macro. However with the default ^KCLOSE macro, which inserts `EX`, this may fail to terminate the editor if buffers are modified. If the process is consequently killed by a non-ignorable signal, we may still loose data. * SIGTERM is used to gracefully shut down, so we now always terminate. Since we have recovery files, they are now dumped before terminating. This makes sure that recovery files are more up-to-date during unexpected but gracefull terminations. * The same functionality is planned on Curses, but requires more fundamental changes (TODO). --- src/interface-curses/interface.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/interface-curses/interface.c') diff --git a/src/interface-curses/interface.c b/src/interface-curses/interface.c index b49540b..569b13a 100644 --- a/src/interface-curses/interface.c +++ b/src/interface-curses/interface.c @@ -125,7 +125,8 @@ teco_console_ctrl_handler(DWORD type) { switch (type) { case CTRL_C_EVENT: - teco_interrupted = TRUE; + case CTRL_BREAK_EVENT: + teco_interrupted = TECO_INTERRUPTED; return TRUE; } @@ -1022,7 +1023,7 @@ teco_interface_getch(gboolean widechar) case KEY_ENTER: return '\n'; case TECO_CTL_KEY('C'): - teco_interrupted = TRUE; + teco_interrupted = TECO_INTERRUPTED; /* fall through */ case TECO_CTL_KEY('D'): /* emulates EOF on stdin */ @@ -1799,7 +1800,7 @@ teco_interface_popup_clear(void) gboolean teco_interface_is_interrupted(void) { - return teco_interrupted != FALSE; + return teco_interrupted == TECO_INTERRUPTED; } #else /* !CURSES_TTY && !PDCURSES_WINCON && !NCURSES_WIN32 */ @@ -1818,7 +1819,7 @@ teco_interface_is_interrupted(void) { if (!teco_interface.input_pad) /* batch mode */ - return teco_interrupted != FALSE; + return teco_interrupted == TECO_INTERRUPTED; /* * NOTE: wgetch() is configured to be nonblocking. @@ -1833,7 +1834,7 @@ teco_interface_is_interrupted(void) GINT_TO_POINTER(key)); } - return teco_interrupted != FALSE; + return teco_interrupted == TECO_INTERRUPTED; } #endif @@ -2122,7 +2123,7 @@ teco_interface_blocking_getch(void) gint key = wgetch(teco_interface.input_pad); teco_memory_start_limiting(); /* allow asynchronous interruptions on */ - teco_interrupted = FALSE; + teco_interrupted = TECO_NORMAL; wtimeout(teco_interface.input_pad, 0); #if defined(CURSES_TTY) || defined(PDCURSES_WINCON) || defined(NCURSES_WIN32) noraw(); /* FIXME: necessary because of NCURSES_WIN32 bug */ -- cgit v1.2.3