From a6d14cecbe1f78802bc22b8a0ad633bc24aab2fc Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Mon, 27 Jan 2014 19:53:17 +0000 Subject: [PATCH] Remove session socket on error signal --- src/main.cc | 2 ++ src/remote.cc | 8 +++++++- src/remote.hh | 2 ++ 3 files changed, 11 insertions(+), 1 deletion(-) 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;