From 0e2f853025309d14d1e442795330885d640e1d33 Mon Sep 17 00:00:00 2001 From: DanS Date: Fri, 9 Oct 2026 21:09:48 -0500 Subject: [PATCH] fix(platform): keep the single-instance lock fd out of child processes On Linux and macOS the lock file was opened without O_CLOEXEC, so xdg-open and the browser it starts, dragonxd and xmrig all inherited it. A clean exit unlocks explicitly, but after a crash or kill the lock stayed held for as long as any of those children ran (indefinitely with "keep daemon running"), and the wallet refused to relaunch. The fd is now opened O_CLOEXEC; nothing else changes. Co-Authored-By: Claude Opus 5.5 --- src/util/single_instance.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/util/single_instance.cpp b/src/util/single_instance.cpp index 418e52c..31bd6d1 100644 --- a/src/util/single_instance.cpp +++ b/src/util/single_instance.cpp @@ -68,7 +68,9 @@ bool SingleInstance::tryLock() #else // Linux/macOS: Use file lock (flock) - lock_fd_ = open(lock_path_.c_str(), O_CREAT | O_RDWR, 0666); + // O_CLOEXEC: children (xdg-open + the browser it starts, dragonxd, xmrig) must not inherit the lock; + // after a crash they'd keep the flock held and block relaunching the wallet. + lock_fd_ = open(lock_path_.c_str(), O_CREAT | O_RDWR | O_CLOEXEC, 0666); if (lock_fd_ < 0) { DEBUG_LOGF("Failed to open lock file %s: %s\n", lock_path_.c_str(), strerror(errno));