Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make socket path unique #2490

Merged
merged 3 commits into from
Oct 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions plugins/ipc/ipc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,9 +324,23 @@ class ipc_plugin_t : public wf::plugin_interface_t
public:
void init() override
{
char *pre_socket = getenv("_WAYFIRE_SOCKET");
const auto& dname = wf::get_core().wayland_display;
std::string socket = pre_socket ?: "/tmp/wayfire-" + dname + ".socket";
char *pre_socket = getenv("_WAYFIRE_SOCKET");
const auto& dname = wf::get_core().wayland_display;
pid_t pid = getpid();
const char *runtime_dir = getenv("XDG_RUNTIME_DIR");

std::string socket;
if (pre_socket)
{
socket = pre_socket;
} else if (runtime_dir)
{
socket = std::string(runtime_dir) + "/wayfire-" + dname + "-" + ".socket";
} else
{
socket = "/tmp/wayfire-" + dname + "-" + std::to_string(pid) + ".socket";
}

setenv("WAYFIRE_SOCKET", socket.c_str(), 1);
server->init(socket);
}
Expand Down
Loading