![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | nps努力 |
![]() |
Reply From: | sash-rc |
If you want a single instance of application, there are several approaches like
-
Lock/PID file: At startup, check if some dummy “lock” file exists. If it does, quit. If not - create such file. Delete lock upon exit. Optionally, write PID to lock-file, and check if such process exists. Will help, when lock-file was not deleted upon abnormal program termination.
-
Dummy network server. Similar as above, but you have to check availability / create a localhost connection on some specific port.
There could be other low-level and platform-dependent solutions.