Skip to content

Stop the whole process tree for every Harness #435

Closed

Description

@JacobStephens2

Parent

#432

What to build

When a Command is interrupted, every process its sessions started is stopped, on every Harness. Today thirdshift signals only the CLI's process group, so a shell command the CLI started in a process group or session of its own (as Grok Build and OpenCode do) keeps running against a worktree thirdshift has left.

Before signalling, thirdshift takes a snapshot of the session's descendant processes with ps, which works on Linux and macOS. It sends each process group in the snapshot the Harness's stop signals in turn, each with the grace period. A second snapshot before SIGKILL catches processes started in the meantime, and then everything gets SIGKILL. Claude and Codex get this as well.

Acceptance criteria

  • A scenario test: a fake session starts a long command in its own session (as setsid does) and records its pid. After the Run is interrupted, that process no longer exists. The test runs on Claude and on Codex.
  • Each Harness's own stop signals and grace period are still sent first, so Codex still gets SIGINT before SIGTERM.
  • A session that exits on its first signal is not waited on any longer than it is today.
  • The tree-stop belongs to the Harness adapter's shared stop path, so every new Harness gets it without code of its own.

Blocked by

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

    ready-for-agentFully specified, ready for an AFK agent

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions