INNER CODE UNIT · Python
check_and_create_lock_file
Matteo842/SaveState · main.py:212
def check_and_create_lock_file() -> tuple:
"""Check if another instance is running via lock file. Returns (is_first_instance, lock_file_path).
On Linux, this provides an additional layer of single-instance detection
that survives crashes better than QSharedMemory alone.
"""
if platform.system() != "Linux":
return (True, None) # On non-Linux, skip file lock
lock_path = get_lock_file_path()
current_pid = os.getpid()
try:
# Check if lock file exists and contains a valid PID
if os.path.exists(lock_path):
try:
with open(lock_path, 'r') as f:
content = f.read().strip()