diff options
author | Sergey Bugaev <bugaevc@serenityos.org> | 2020-05-28 18:25:34 +0300 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-05-29 07:53:30 +0200 |
commit | ec4902d1dd039436118cd821b76dbacec6d7cdca (patch) | |
tree | c81f7942560629fc8539c16d91a5a4557a90503a | |
parent | 8afcf0d87a5ab946aaa3b2a12835214eeee6e4bc (diff) | |
download | serenity-ec4902d1dd039436118cd821b76dbacec6d7cdca.zip |
LibCore+Inspector: Move RPC sockets to /tmp/rpc
We have a hierarchical filesystem, let's make use of it :^)
-rw-r--r-- | DevTools/Inspector/RemoteProcess.cpp | 2 | ||||
-rw-r--r-- | Libraries/LibCore/EventLoop.cpp | 19 |
2 files changed, 18 insertions, 3 deletions
diff --git a/DevTools/Inspector/RemoteProcess.cpp b/DevTools/Inspector/RemoteProcess.cpp index 4c642ee45e..d1ceb61c3d 100644 --- a/DevTools/Inspector/RemoteProcess.cpp +++ b/DevTools/Inspector/RemoteProcess.cpp @@ -188,7 +188,7 @@ void RemoteProcess::update() } }; - auto success = m_socket->connect(Core::SocketAddress::local(String::format("/tmp/rpc.%d", m_pid))); + auto success = m_socket->connect(Core::SocketAddress::local(String::format("/tmp/rpc/%d", m_pid))); if (!success) { fprintf(stderr, "Couldn't connect to PID %d\n", m_pid); exit(1); 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 <string.h> #include <sys/select.h> #include <sys/socket.h> +#include <sys/stat.h> #include <sys/time.h> #include <time.h> #include <unistd.h> @@ -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; |