Merge pull request #4408 from lfos/fix-hyprland-ipc-destructor

Prevent child zombie process from tearing down Hyprland IPC
This commit is contained in:
Alexis Rouillard
2025-10-01 14:21:17 +02:00
committed by GitHub
2 changed files with 6 additions and 0 deletions

View File

@ -42,6 +42,7 @@ class IPC {
util::JsonParser parser_;
std::list<std::pair<std::string, EventHandler*>> callbacks_;
int socketfd_; // the hyprland socket file descriptor
pid_t socketOwnerPid_;
bool running_ = true;
};

View File

@ -46,9 +46,14 @@ std::filesystem::path IPC::getSocketFolder(const char* instanceSig) {
IPC::IPC() {
// will start IPC and relay events to parseIPC
ipcThread_ = std::thread([this]() { socketListener(); });
socketOwnerPid_ = getpid();
}
IPC::~IPC() {
// Do no stop Hyprland IPC if a child process (with successful fork() but
// failed exec()) exits.
if (getpid() != socketOwnerPid_) return;
running_ = false;
spdlog::info("Hyprland IPC stopping...");
if (socketfd_ != -1) {