fix: deskflow-core always starts a new instance without --new-instance

fixes: #9216
This commit is contained in:
sithlord48 2025-11-26 15:53:54 -05:00 committed by Chris Rizzitello
parent 2f5166fafa
commit 52e0daba0f

View file

@ -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();