Keeping a single instance of an applicaton
-
Hey guys, I am wondering what's the proper and cross platform (if possible) way to keep a single instance of an application, with some additional IPC (like making the already running app visible if it's being ran again). Does anyone have any advice? Thanks in advance
-
Hi
Normally QSharedMemory or QLocalServer is used.
However, its a pretty common requirement so
maybe this could work for you ?
https://github.com/itay-grudev/SingleApplicationinfo:
https://stackoverflow.com/questions/5006547/qt-best-practice-for-a-single-instance-app-protection -
@mrjj Hey there, thanks for responding! My concern with any of these methods is an edge case (such as an application crash, or even system crash), leading to improper cleanup and because of that failure to restart the application later, especially on Windows. Looking through the implementation of SingleApplication it does not seem like it handles such situations on Windows. On Unix it makes handlers for many signals to clean up the shared memory, but there seems to be no analogue for that on Windows. Does Windows handle shared memory differently?
-
Hi,
Did you also check the QSingleApplication from the Qt solutions ?