浏览代码

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 年之前
父节点
当前提交
7e5f1fa895
共有 1 个文件被更改,包括 2 次插入2 次删除
  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) {
     if (m_configuration.m_signal_mode == Configuration::WithSignalHandlers) {
         m_signal_handlers.append(Core::EventLoop::register_signal(SIGINT, [this](int) {
         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) {
         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(); });
         }));
         }));
     }
     }