INNER CODE UNIT · Python
cleanup_lock_file
Matteo842/SaveState · main.py:256
def cleanup_lock_file():
"""Remove the lock file on exit."""
if platform.system() != "Linux":
return
try:
lock_path = get_lock_file_path()
if os.path.exists(lock_path):
# Only remove if it's our PID
try:
with open(lock_path, 'r') as f:
stored_pid = int(f.read().strip())
if stored_pid == os.getpid():
os.unlink(lock_path)
logging.debug(f"Removed lock file: {lock_path}")
except Exception:
pass
except Exception as e:
logging.debug(f"Error cleaning up lock file: {e}")