aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/interface-curses
diff options
context:
space:
mode:
authorRobin Haberkorn <rhaberkorn@fmsbw.de>2026-04-12 21:47:58 +0200
committerRobin Haberkorn <rhaberkorn@fmsbw.de>2026-04-12 23:00:40 +0200
commit0a8770ac7d382df8976b2448fccc6cfe434cd4d1 (patch)
tree5551617b6bd61b069c9d538f19aea2dbc94b44c1 /src/interface-curses
parent0e3d6c84a52326a1069fe4f7adc2930b974dfa5f (diff)
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).
Diffstat (limited to 'src/interface-curses')
-rw-r--r--src/interface-curses/interface.c13
1 files changed, 7 insertions, 6 deletions
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 <CTRL/C> */
- 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 */