From 7e5f1fa89590abbf1e926f4196030159be23e7b3 Mon Sep 17 00:00:00 2001 From: Ali Mohammad Pur Date: Wed, 7 Jun 2023 14:39:35 +0330 Subject: [PATCH] LibLine: Defer handling SIGWINCH and SIGINT Performing these immediately can introduce a race condition between the user's signal-related logic and LibLine's own, so defer the handlers to make sure they run when our terminal IO cannot interfere with the user's. --- Userland/Libraries/LibLine/Editor.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibLine/Editor.cpp b/Userland/Libraries/LibLine/Editor.cpp index 08a96a7141..1840148223 100644 --- a/Userland/Libraries/LibLine/Editor.cpp +++ b/Userland/Libraries/LibLine/Editor.cpp @@ -582,11 +582,11 @@ void Editor::initialize() if (m_configuration.m_signal_mode == Configuration::WithSignalHandlers) { m_signal_handlers.append(Core::EventLoop::register_signal(SIGINT, [this](int) { - interrupted().release_value_but_fixme_should_propagate_errors(); + Core::EventLoop::current().deferred_invoke([this] { interrupted().release_value_but_fixme_should_propagate_errors(); }); })); m_signal_handlers.append(Core::EventLoop::register_signal(SIGWINCH, [this](int) { - resized().release_value_but_fixme_should_propagate_errors(); + Core::EventLoop::current().deferred_invoke([this] { resized().release_value_but_fixme_should_propagate_errors(); }); })); }