diff --git a/src/main.cc b/src/main.cc index 721ee933..fb2b2307 100644 --- a/src/main.cc +++ b/src/main.cc @@ -203,6 +203,8 @@ void signal_handler(int signal) case SIGTERM: text = "SIGTERM"; break; } on_assert_failed(text); + if (Server::has_instance()) + Server::instance().close_session(); abort(); } diff --git a/src/remote.cc b/src/remote.cc index ecd7da1c..ee7d7602 100644 --- a/src/remote.cc +++ b/src/remote.cc @@ -541,10 +541,16 @@ Server::Server(String session_name) m_listener.reset(new FDWatcher{listen_sock, accepter}); } -Server::~Server() +void Server::close_session() { unlink(("/tmp/kak-" + m_session).c_str()); close(m_listener->fd()); + m_listener.reset(); +} + +Server::~Server() +{ + close_session(); } } diff --git a/src/remote.hh b/src/remote.hh index 309770da..4682b3d3 100644 --- a/src/remote.hh +++ b/src/remote.hh @@ -36,6 +36,8 @@ struct Server : public Singleton ~Server(); const String& session() const { return m_session; } + void close_session(); + private: String m_session; std::unique_ptr m_listener;