mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 22:37:34 +00:00
LibCore+Inspector: Move RPC sockets to /tmp/rpc
We have a hierarchical filesystem, let's make use of it :^)
This commit is contained in:
parent
8afcf0d87a
commit
ec4902d1dd
2 changed files with 18 additions and 3 deletions
|
@ -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) {
|
if (!success) {
|
||||||
fprintf(stderr, "Couldn't connect to PID %d\n", m_pid);
|
fprintf(stderr, "Couldn't connect to PID %d\n", m_pid);
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
|
@ -45,6 +45,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/select.h>
|
#include <sys/select.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
@ -250,8 +251,22 @@ EventLoop::~EventLoop()
|
||||||
|
|
||||||
bool EventLoop::start_rpc_server()
|
bool EventLoop::start_rpc_server()
|
||||||
{
|
{
|
||||||
auto rpc_path = String::format("/tmp/rpc.%d", getpid());
|
// Create /tmp/rpc if it doesn't exist.
|
||||||
int rc = unlink(rpc_path.characters());
|
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) {
|
if (rc < 0 && errno != ENOENT) {
|
||||||
perror("unlink");
|
perror("unlink");
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue