From 52e0daba0f0ffbe4533d1432f0826deccd051784 Mon Sep 17 00:00:00 2001 From: sithlord48 Date: Wed, 26 Nov 2025 15:53:54 -0500 Subject: [PATCH] fix: deskflow-core always starts a new instance without --new-instance fixes: #9216 --- src/apps/deskflow-core/deskflow-core.cpp | 25 +++++++++++------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/src/apps/deskflow-core/deskflow-core.cpp b/src/apps/deskflow-core/deskflow-core.cpp index bef870b57..f4601b1c0 100644 --- a/src/apps/deskflow-core/deskflow-core.cpp +++ b/src/apps/deskflow-core/deskflow-core.cpp @@ -66,22 +66,19 @@ int main(int argc, char **argv) return s_exitSuccess; } - if (parser.singleInstanceOnly()) { - // Before we check any more args we need to check for a duplicate process. - // Create a shared memory segment with a unique key - // This is to prevent a new instance from running if one is already running - QSharedMemory sharedMemory(kCoreBinName); + // Before we check any more args we need to check for a duplicate process. + // Create a shared memory segment with a unique key + // This is to prevent a new instance from running if one is already running + QSharedMemory sharedMemory(kCoreBinName); - // Attempt to attach first and detach in order to clean up stale shm chunks - // This can happen if the previous instance was killed or crashed - if (sharedMemory.attach()) - sharedMemory.detach(); + // Attempt to attach first and detach in order to clean up stale shm chunks + // This can happen if the previous instance was killed or crashed + if (sharedMemory.attach()) + sharedMemory.detach(); - // If we can create 1 byte of SHM we are the only instance - if (!sharedMemory.create(1)) { - LOG_WARN("an instance of deskflow core is already running"); - return s_exitDuplicate; - } + if (!sharedMemory.create(1) && parser.singleInstanceOnly()) { + LOG_WARN("an instance of deskflow core is already running"); + return s_exitDuplicate; } parser.parse();