diff --git a/src/client_manager.hh b/src/client_manager.hh index 3c964b2c..8501e3ea 100644 --- a/src/client_manager.hh +++ b/src/client_manager.hh @@ -49,9 +49,9 @@ public: Client& get_client(const Context& context); Client& get_client(const String& name); void set_client_name(Client& client, String name); + void remove_client(Client& client); private: - void remove_client(Client& client); String generate_name() const; std::vector> m_clients; diff --git a/src/main.cc b/src/main.cc index bd5b43b2..927aebb0 100644 --- a/src/main.cc +++ b/src/main.cc @@ -134,8 +134,13 @@ void create_local_client(const String& init_command) }; UserInterface* ui = new LocalNCursesUI{}; - ClientManager::instance().create_client( + static Client* client = ClientManager::instance().create_client( std::unique_ptr{ui}, init_command); + signal(SIGHUP, [](int) { + if (client) + ClientManager::instance().remove_client(*client); + client = nullptr; + }); } void signal_handler(int signal)