Godot project program, how to set only open once?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By nps努力

Detail


I want to achieve the effect that only one application can be opened while the program is running

:bust_in_silhouette: Reply From: sash-rc

If you want a single instance of application, there are several approaches like

  1. 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.

  2. 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.