From ec4902d1dd039436118cd821b76dbacec6d7cdca Mon Sep 17 00:00:00 2001 From: Sergey Bugaev Date: Thu, 28 May 2020 18:25:34 +0300 Subject: LibCore+Inspector: Move RPC sockets to /tmp/rpc We have a hierarchical filesystem, let's make use of it :^) --- Libraries/LibCore/EventLoop.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'Libraries') diff --git a/Libraries/LibCore/EventLoop.cpp b/Libraries/LibCore/EventLoop.cpp index fdd82b8064..36e178f3d6 100644 --- a/Libraries/LibCore/EventLoop.cpp +++ b/Libraries/LibCore/EventLoop.cpp @@ -45,6 +45,7 @@ #include #include #include +#include #include #include #include @@ -250,8 +251,22 @@ EventLoop::~EventLoop() bool EventLoop::start_rpc_server() { - auto rpc_path = String::format("/tmp/rpc.%d", getpid()); - int rc = unlink(rpc_path.characters()); + // Create /tmp/rpc if it doesn't exist. + int rc = mkdir("/tmp/rpc", 0777); + if (rc == 0) { + // Ensure it gets created as 0777 despite our umask. + rc = chmod("/tmp/rpc", 0777); + if (rc < 0) { + perror("chmod /tmp/rpc"); + // Continue further. + } + } else if (errno != EEXIST) { + perror("mkdir /tmp/rpc"); + return false; + } + + auto rpc_path = String::format("/tmp/rpc/%d", getpid()); + rc = unlink(rpc_path.characters()); if (rc < 0 && errno != ENOENT) { perror("unlink"); return false; -- cgit v1.2.3