fix: deskflow-core always starts a new instance without --new-instance
fixes: #9216
This commit is contained in:
parent
2f5166fafa
commit
52e0daba0f
1 changed files with 11 additions and 14 deletions
|
|
@ -66,22 +66,19 @@ int main(int argc, char **argv)
|
||||||
return s_exitSuccess;
|
return s_exitSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parser.singleInstanceOnly()) {
|
// Before we check any more args we need to check for a duplicate process.
|
||||||
// Before we check any more args we need to check for a duplicate process.
|
// Create a shared memory segment with a unique key
|
||||||
// Create a shared memory segment with a unique key
|
// This is to prevent a new instance from running if one is already running
|
||||||
// This is to prevent a new instance from running if one is already running
|
QSharedMemory sharedMemory(kCoreBinName);
|
||||||
QSharedMemory sharedMemory(kCoreBinName);
|
|
||||||
|
|
||||||
// Attempt to attach first and detach in order to clean up stale shm chunks
|
// 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
|
// This can happen if the previous instance was killed or crashed
|
||||||
if (sharedMemory.attach())
|
if (sharedMemory.attach())
|
||||||
sharedMemory.detach();
|
sharedMemory.detach();
|
||||||
|
|
||||||
// If we can create 1 byte of SHM we are the only instance
|
if (!sharedMemory.create(1) && parser.singleInstanceOnly()) {
|
||||||
if (!sharedMemory.create(1)) {
|
LOG_WARN("an instance of deskflow core is already running");
|
||||||
LOG_WARN("an instance of deskflow core is already running");
|
return s_exitDuplicate;
|
||||||
return s_exitDuplicate;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
parser.parse();
|
parser.parse();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue