Skip to content

Bug: process_is_alive crashes Yoke runtime deployments on Windows (OSError: [WinError 87]) #2

Description

@Adityakk9031

Describe the bug

The process_is_alive function in src/yoke/providers/runtime_deployment.py crashes on Windows when attempting to check if a process is still running during the cleanup of stale temporary runtime deployments.

When os.kill(pid, 0) is called on a non-existent PID on Windows, it raises a generic OSError: [WinError 87] The parameter is incorrect, rather than the ProcessLookupError seen on Unix systems. Because this exception is unhandled, it bubbles up and completely crashes the deploy_runtime function, preventing the harness from starting.

Steps to reproduce

  1. Run Yoke on a Windows machine.
  2. Have a stale/abandoned Yoke deployment directory (e.g. yoke-codex-<pid>-...) in your temporary folder, where the <pid> no longer exists.
  3. Attempt to run any agent via Yoke.
  4. The application crashes during reclaim_stale_deployments.

Expected behavior

The function should safely catch the Windows-specific OSError and return False, correctly identifying the process as dead and allowing the stale directory to be cleaned up without crashing.

Suggested Fix

Update process_is_alive in src/yoke/providers/runtime_deployment.py to catch OSError:

def process_is_alive(pid: int) -> bool:
    if pid == os.getpid():
        return True
    try:
        os.kill(pid, 0)
    except ProcessLookupError:
        return False
    except PermissionError:
        return True
    except OSError:
        # On Windows, os.kill(pid, 0) for a non-existent process raises OSError: [WinError 87]
        return False
    return True

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions