aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main.c
diff options
context:
space:
mode:
authorRobin Haberkorn <rhaberkorn@fmsbw.de>2026-04-19 00:02:16 +0200
committerRobin Haberkorn <rhaberkorn@fmsbw.de>2026-04-19 00:02:16 +0200
commitd4c864e92f89003e73883fe0b259e6c2e3bfb4f3 (patch)
tree9a13565b8a5595af4ef628b9a3587d84021a52e5 /src/main.c
parent7ac75b4053cbc1c758d38732fcc4d1d93d4a9fd8 (diff)
UNIX: do not automatically restart syscalls on SIGINTHEADmaster-fmsbw-cimaster
* signal() sets SA_RESTART by default. * Some syscalls can theoretically block indefinitely. Even opening a special file could result in an indefinitely blocking operation, that should be interruptible. You must still poll teco_interrupted in these read() loops of course. * Also makes sure that clipboard operations are interruptible even if $SCITECO_CLIPBOARD_GET blocks. Although I couldn't provoke problems in practice, I did observe hangs with xclip on Wayland on Linux, that could only be resolved by manually killing xclip.
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/main.c b/src/main.c
index 33ab26f..29ef024 100644
--- a/src/main.c
+++ b/src/main.c
@@ -388,7 +388,21 @@ main(int argc, char **argv)
getchar();
#endif
+ /*
+ * FIXME: Gracefully handle SIGTERM.
+ * This however would require polling for the flag in Curses
+ * getch() loops.
+ * GTK already catches SIGTERM.
+ */
+#ifdef HAVE_SIGACTION
+ static const struct sigaction sigint = {
+ .sa_handler = teco_sigint_handler,
+ .sa_flags = 0 /* don't auto-restart syscalls */
+ };
+ sigaction(SIGINT, &sigint, NULL);
+#else
signal(SIGINT, teco_sigint_handler);
+#endif
/*
* Important for Unicode handling in curses and glib.