summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2014-01-27 19:53:17 +0000
committerMaxime Coste <frrrwww@gmail.com>2014-01-27 19:53:17 +0000
commita6d14cecbe1f78802bc22b8a0ad633bc24aab2fc (patch)
treef500c43404138e5ea0c9e79567f3dce63334dcd4 /src
parentbbf48e1d39d34b02c54f7b5104b0ff17dff3d7b5 (diff)
Remove session socket on error signal
Diffstat (limited to 'src')
-rw-r--r--src/main.cc2
-rw-r--r--src/remote.cc8
-rw-r--r--src/remote.hh2
3 files changed, 11 insertions, 1 deletions
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>
~Server();
const String& session() const { return m_session; }
+ void close_session();
+
private:
String m_session;
std::unique_ptr<FDWatcher> m_listener;