From 5e041e6e5a527e501f76ca1d527edb89e9719017 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Wed, 13 Nov 2024 17:32:13 +0200 Subject: [PATCH] WindowServer: Make all terminating signals exit cleanly This allows window server to restore input handling to TTY if window server crashes on page fault or some other unexpected exception. --- userspace/programs/WindowServer/main.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/userspace/programs/WindowServer/main.cpp b/userspace/programs/WindowServer/main.cpp index ca334cd9..34f8e711 100644 --- a/userspace/programs/WindowServer/main.cpp +++ b/userspace/programs/WindowServer/main.cpp @@ -165,6 +165,19 @@ int main() atexit([]() { tty_ctrl(STDIN_FILENO, TTY_CMD_SET, TTY_FLAG_ENABLE_INPUT); }); + constexpr int non_terminating_signals[] { + SIGCHLD, + SIGCONT, + SIGSTOP, + SIGTSTP, + SIGTTIN, + SIGTTOU, + }; + for (int sig = _SIGMIN; sig <= _SIGMAX; sig++) + signal(sig, exit); + for (int sig : non_terminating_signals) + signal(sig, SIG_DFL); + MUST(LibInput::KeyboardLayout::initialize()); MUST(LibInput::KeyboardLayout::get().load_from_file("/usr/share/keymaps/us.keymap"_sv));