INNER CODE UNIT · Python
get_lock_file_path
Matteo842/SaveState · main.py:186
def get_lock_file_path() -> str:
"""Get the path for the lock file on Linux."""
runtime_dir = os.environ.get("XDG_RUNTIME_DIR")
if not runtime_dir:
try:
uid = os.getuid() # type: ignore[attr-defined]
runtime_dir = f"/run/user/{uid}"
except Exception:
runtime_dir = "/tmp"
return os.path.join(runtime_dir, "savestate.lock")
def is_process_running(pid: int) -> bool:
"""Check if a process with the given PID is still running."""
if platform.system() != "Linux":
return False
try:
# On Linux, sending signal 0 checks if process exists without killing it