INNER CODE UNIT · Python

is_process_running

Matteo842/SaveState · main.py:198

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
        os.kill(pid, 0)
        return True
    except OSError:
        return False
    except Exception:
        return False


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

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…