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.
This commit is contained in:
Maxime Coste 2018-05-23 08:14:56 +10:00
parent 878d2a4bdb
commit 4ef5c80724
3 changed files with 7 additions and 1 deletions

View File

@ -526,7 +526,7 @@ int run_client(StringView session, StringView name, StringView client_init,
client_init, std::move(init_coord)}; client_init, std::move(init_coord)};
if (suspend) if (suspend)
raise(SIGTSTP); raise(SIGTSTP);
while (not client.exit_status()) while (not client.exit_status() and client.is_ui_ok())
event_manager.handle_next_events(EventMode::Normal); event_manager.handle_next_events(EventMode::Normal);
return *client.exit_status(); return *client.exit_status();
} }

View File

@ -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) void send_command(StringView session, StringView command)
{ {
int sock = connect_to(session); int sock = connect_to(session);

View File

@ -34,6 +34,7 @@ public:
int pid, const EnvVarMap& env_vars, StringView init_command, int pid, const EnvVarMap& env_vars, StringView init_command,
Optional<BufferCoord> init_coord); Optional<BufferCoord> init_coord);
bool is_ui_ok() const;
const Optional<int>& exit_status() const { return m_exit_status; } const Optional<int>& exit_status() const { return m_exit_status; }
private: private:
std::unique_ptr<UserInterface> m_ui; std::unique_ptr<UserInterface> m_ui;