Skip to content

install.ps1: a shim gh's child that keeps the output pipe can outlive the 10-second deadline #558

Closed

Description

@devswha

What

install.ps1's Invoke-GhApi (#550) gives gh 10 seconds to exit and 2 more for its output to complete, then runs taskkill /T /F on the launched process. When gh is a .cmd/.bat shim run through cmd.exe, the shim can start a child that inherits the stdout pipe and then exit: WaitForExit succeeds, $said.Wait(2000) times out, and taskkill targets the launcher that has already exited, so the child can live on. On Windows PowerShell's .NET Framework, Process.Dispose() also leaves the StandardOutput/StandardError readers open, so an outstanding read keeps the pipe handles and a worker.

The official gh.exe is not a shim, so this does not affect a normal install; it affects shim installs and the test stand-in.

Where

install.ps1, Invoke-GhApi: the timeout branch and the finally.

Possible fix

Contain descendants from launch (a Windows job object, which in PowerShell 5.1 means P/Invoke) and close both readers explicitly in finally (guarding the close against a pending ReadToEndAsync). Add an extracted-helper test where the launcher exits while a child retains the output.

Two Low notes on install.sh's gh watcher from the same review: its current sleep 1 is briefly orphaned after a quick call (it expires within a second), and the watcher identifies gh by PID only, so a PID reused within its one-second look could be signalled; a single supervisor that owns the child would remove both.

Found by

Codex gpt-6.1-sol delta review of #550 at 73afcb8 (Medium). Left for a follow-up at merge time.

Activity

  1. added a commit that references this issue on Oct 14, 2026
    e2bab55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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