Fix: Remove MSG_NOSIGNAL from HelperIPC.cpp, fix include paths for macOS
Browse files12334567891010111213141516171819208 unmodified lines293031323334353637383940363741424344454246474849475051525317 unmodified lines7172737174757677787977808182832 unmodified lines868788868789909192937 unmodified lines1011021031011041051061071081091071101111122 unmodified lines115116117116118119120#include "HelperIPC.h"#include "HelperPluginHost.h"#include "../Shared/IPCProtocol.h"#include "IPCProtocol.h"
#include <sys/socket.h>#include <sys/un.h>#include <unistd.h>#include <poll.h>#include <signal.h>
// Using nlohmann json (shared with parent)#include "json.hpp"using json = nlohmann::json;
HelperIPC::HelperIPC(int parentPid, HelperPluginHost& host) : parentPid(parentPid), host(host){ signal(SIGPIPE, SIG_IGN);}
HelperIPC::~HelperIPC()8 unmodified lines socketFd = socket(AF_UNIX, SOCK_STREAM, 0); if (socketFd < 0) return false;
// Set SO_NOSIGPIPE (macOS) int nosigpipe = 1; setsockopt(socketFd, SOL_SOCKET, SO_NOSIGPIPE, &nosigpipe, sizeof(nosigpipe));
struct sockaddr_un addr; memset(&addr, 0, sizeof(addr)); addr.sun_family = AF_UNIX; strncpy(addr.sun_path, socketPath.c_str(), sizeof(addr.sun_path) - 1);
// Try to connect (parent should have the socket listening already) int retries = 50; // 5 seconds total int retries = 50; while (retries-- > 0) { if (::connect(socketFd, (struct sockaddr*)&addr, sizeof(addr)) == 0) { // Connected — start listening running.store(true); listenThread = std::thread([this]() { listenLoop(); }); return true; } usleep(100000); // 100ms usleep(100000); }
close(socketFd);17 unmodified linesvoid HelperIPC::sendReady(){ json msg = {{"notify", "ready"}}; sendMessage(msg.dump()); sendMessage(juce::String(msg.dump()));}
void HelperIPC::sendParamChanged(int index, float value){ json msg = {{"notify", "param_changed"}, {"index", index}, {"value", value}}; sendMessage(msg.dump()); sendMessage(juce::String(msg.dump()));}
void HelperIPC::sendMessage(const juce::String& jsonStr)2 unmodified lines
auto data = jsonStr + "\n"; auto bytes = data.toRawUTF8(); auto len = data.getNumBytesAsUTF8(); ::send(socketFd, bytes, len, MSG_NOSIGNAL); auto len = (size_t)data.getNumBytesAsUTF8(); ::send(socketFd, bytes, len, 0);}
void HelperIPC::listenLoop()7 unmodified lines pfd.fd = socketFd; pfd.events = POLLIN;
int ret = poll(&pfd, 1, 200); // 200ms timeout int ret = poll(&pfd, 1, 200); if (ret <= 0) continue;
ssize_t n = recv(socketFd, chunk, sizeof(chunk) - 1, 0); if (n <= 0) { // Parent disconnected or error DBG("HelperIPC: Parent disconnected"); juce::JUCEApplication::getInstance()->systemRequestedQuit(); return;2 unmodified lines chunk[n] = '\0'; buffer += chunk;
// Process complete messages (newline-delimited) size_t pos; while ((pos = buffer.find('\n')) != std::string::npos) {Source/Helper/HelperIPC.cpp+14-13