Remove session socket on error signal

This commit is contained in:
Maxime Coste 2014-01-27 19:53:17 +00:00
parent bbf48e1d39
commit a6d14cecbe
3 changed files with 11 additions and 1 deletions

View File

@ -203,6 +203,8 @@ void signal_handler(int signal)
case SIGTERM: text = "SIGTERM"; break; case SIGTERM: text = "SIGTERM"; break;
} }
on_assert_failed(text); on_assert_failed(text);
if (Server::has_instance())
Server::instance().close_session();
abort(); abort();
} }

View File

@ -541,10 +541,16 @@ Server::Server(String session_name)
m_listener.reset(new FDWatcher{listen_sock, accepter}); m_listener.reset(new FDWatcher{listen_sock, accepter});
} }
Server::~Server() void Server::close_session()
{ {
unlink(("/tmp/kak-" + m_session).c_str()); unlink(("/tmp/kak-" + m_session).c_str());
close(m_listener->fd()); close(m_listener->fd());
m_listener.reset();
}
Server::~Server()
{
close_session();
} }
} }

View File

@ -36,6 +36,8 @@ struct Server : public Singleton<Server>
~Server(); ~Server();
const String& session() const { return m_session; } const String& session() const { return m_session; }
void close_session();
private: private:
String m_session; String m_session;
std::unique_ptr<FDWatcher> m_listener; std::unique_ptr<FDWatcher> m_listener;