From 4ef5c807247ec28612f5d1330b23ee56679c5c6b Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Wed, 23 May 2018 08:14:56 +1000 Subject: [PATCH] Fix Kakoune client busy looping on SIGHUP Pure clients never quitted when they got SIGHUP after recent changes to add is_ok to UserInterface. run_client now tracks the UI state as well and quits if the UI gets killed. --- src/main.cc | 2 +- src/remote.cc | 5 +++++ src/remote.hh | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main.cc b/src/main.cc index a83ebe74..84cf162b 100644 --- a/src/main.cc +++ b/src/main.cc @@ -526,7 +526,7 @@ int run_client(StringView session, StringView name, StringView client_init, client_init, std::move(init_coord)}; if (suspend) raise(SIGTSTP); - while (not client.exit_status()) + while (not client.exit_status() and client.is_ui_ok()) event_manager.handle_next_events(EventMode::Normal); return *client.exit_status(); } diff --git a/src/remote.cc b/src/remote.cc index c5c04915..da441bd8 100644 --- a/src/remote.cc +++ b/src/remote.cc @@ -668,6 +668,11 @@ RemoteClient::RemoteClient(StringView session, StringView name, std::unique_ptr< }}); } +bool RemoteClient::is_ui_ok() const +{ + return m_ui->is_ok(); +} + void send_command(StringView session, StringView command) { int sock = connect_to(session); diff --git a/src/remote.hh b/src/remote.hh index a8056fca..19eb0071 100644 --- a/src/remote.hh +++ b/src/remote.hh @@ -34,6 +34,7 @@ public: int pid, const EnvVarMap& env_vars, StringView init_command, Optional init_coord); + bool is_ui_ok() const; const Optional& exit_status() const { return m_exit_status; } private: std::unique_ptr m_ui;