Also mask signals when SIGNALFD is not available
This makes behavior across platforms consistent. Fixes #4636
This commit is contained in:
parent
ea5ffa4304
commit
7fe5c79d53
@ -65,6 +65,8 @@ Detailed list of changes
|
||||
|
||||
- When using the :code:`include` directive in :file:`kitty.conf` make the environment variable :envvar:`KITTY_OS` available for OS specific config
|
||||
|
||||
- Wayland: Fix signal handling not working with some GPU drivers (:iss:`4636`)
|
||||
|
||||
0.26.5 [2022-11-07]
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
@ -124,10 +124,6 @@ set_maximum_wait(monotonic_t val) {
|
||||
|
||||
static void
|
||||
mask_variadic_signals(int sentinel, ...) {
|
||||
// only need to mask signals when using SIGNAL_FD as signal actions are inherited by threads
|
||||
// and only on Linux do we have reports of signals not being handled presumably because libwayland starts
|
||||
// a thread behind our backs. See https://github.com/kovidgoyal/kitty/issues/4636
|
||||
#ifdef HAS_SIGNAL_FD
|
||||
sigset_t signals;
|
||||
sigemptyset(&signals);
|
||||
va_list valist;
|
||||
@ -138,9 +134,17 @@ mask_variadic_signals(int sentinel, ...) {
|
||||
sigaddset(&signals, sig);
|
||||
}
|
||||
va_end(valist);
|
||||
#ifdef HAS_SIGNAL_FD
|
||||
sigprocmask(SIG_BLOCK, &signals, NULL);
|
||||
#else
|
||||
(void)sentinel;
|
||||
struct sigaction act = {.sa_handler=SIG_IGN, .sa_flags=SA_RESTART, .sa_mask = signals};
|
||||
va_start(valist, sentinel);
|
||||
while (true) {
|
||||
int sig = va_arg(valist, int);
|
||||
if (sig == sentinel) break;
|
||||
sigaction(sig, &act, NULL);
|
||||
}
|
||||
va_end(valist);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -103,7 +103,6 @@ def init_glfw_module(glfw_module: str, debug_keyboard: bool = False, debug_rende
|
||||
|
||||
|
||||
def init_glfw(opts: Options, debug_keyboard: bool = False, debug_rendering: bool = False) -> str:
|
||||
mask_kitty_signals_process_wide()
|
||||
glfw_module = 'cocoa' if is_macos else ('wayland' if is_wayland(opts) else 'x11')
|
||||
init_glfw_module(glfw_module, debug_keyboard, debug_rendering)
|
||||
return glfw_module
|
||||
@ -464,6 +463,11 @@ def _main() -> None:
|
||||
log_error('Failed to set locale, ignoring')
|
||||
with suppress(AttributeError): # python compiled without threading
|
||||
sys.setswitchinterval(1000.0) # we have only a single python thread
|
||||
|
||||
# mask the signals now as on some platforms the display backend starts
|
||||
# threads. These threads must not handle the masked signals, to ensure
|
||||
# kitty can handle them. See https://github.com/kovidgoyal/kitty/issues/4636
|
||||
mask_kitty_signals_process_wide()
|
||||
init_glfw(opts, cli_opts.debug_keyboard, cli_opts.debug_rendering)
|
||||
if cli_opts.watcher:
|
||||
from .window import global_watchers
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user