From bb6759986ebed45c96c525e3e1023405d7daf058 Mon Sep 17 00:00:00 2001 From: apio Date: Sat, 7 Sep 2024 17:33:01 +0200 Subject: [PATCH] libos/LocalServer: Clean up socket file on exit This doesn't work if the process is killed by an unhandled signal. --- libos/include/os/LocalServer.h | 1 + libos/src/LocalServer.cpp | 2 ++ 2 files changed, 3 insertions(+) diff --git a/libos/include/os/LocalServer.h b/libos/include/os/LocalServer.h index 1adfa92a..ddc38fd1 100644 --- a/libos/include/os/LocalServer.h +++ b/libos/include/os/LocalServer.h @@ -136,6 +136,7 @@ namespace os ~LocalServer(); private: + StringView m_path; int m_fd; bool m_blocking; }; diff --git a/libos/src/LocalServer.cpp b/libos/src/LocalServer.cpp index 94e5d555..89ef2c85 100644 --- a/libos/src/LocalServer.cpp +++ b/libos/src/LocalServer.cpp @@ -43,6 +43,7 @@ namespace os fcntl(sockfd, F_SETFD, FD_CLOEXEC); server->m_fd = sockfd; + server->m_path = path; return server; } @@ -63,6 +64,7 @@ namespace os LocalServer::~LocalServer() { close(m_fd); + os::FileSystem::remove(m_path); } LocalServer::Client::Client(Client&& other) : m_fd(other.m_fd)