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.
This commit is contained in:
Ali Mohammad Pur 2023-06-07 14:39:35 +03:30 committed by Ali Mohammad Pur
parent fb979dcf34
commit 7e5f1fa895

View file

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