Browse Source

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.
Ali Mohammad Pur 2 years ago
parent
commit
7e5f1fa895
1 changed files with 2 additions and 2 deletions
  1. 2 2
      Userland/Libraries/LibLine/Editor.cpp

+ 2 - 2
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(); });
         }));
     }