Skip to content

Close Linux PTY process groups after the leader exits - #163

Merged
tony merged 3 commits into
masterfrom
fix/89-pty-group-lifetime
Dec 5, 2026
Merged

tony merged 3 commits into
masterfrom
fix/89-pty-group-lifetime

Conversation

@tony

@tony tony commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

Refs #89

What changed, and why:

With group pidfd signaling available, PTY close can signal surviving members of the original group after the direct child exits. PtySession.closed_before_eof records whether close began before terminal EOF. When pidfd handoff is unavailable, close signals the group while the direct child runs. A surviving worker can receive a write error when the master closes. Waiting for natural EOF preserves its final output.

Checks run:

On Linux, Ruff formatting and lint, ty for Python 3.12 through 3.15, the full pytest suite with doctests, compiled Ghostty comparisons, and the Sphinx warnings-as-errors build passed. Native Linux group-pidfd and forced fallback probes covered both natural EOF and explicit close.

Tool use:

Codex prepared the change and ran the local checks. A separate Codex reviewer replayed the changed behavior and checked the publication tree against the reviewed patch.

tony added a commit that referenced this pull request Dec 3, 2026
why: Readers need the behavior and scope of this change at release.

what:
- Add the unreleased entry for PR #163
- Preserve previously published notes and the parent branch's entries
@tony
tony marked this pull request as ready for review December 3, 2026 01:36
@tony
tony force-pushed the fix/89-pty-group-lifetime branch from 7e988d3 to db913ff Compare December 3, 2026 23:58
tony added 3 commits December 5, 2026 07:43
why: A PTY worker can outlive the leader of its original process group.

what:
- Retain the Linux group pidfd handed off by the launcher.
- Signal surviving group members after direct-child exit.
- Track close before terminal EOF and document fallback behavior.
- Cover natural EOF, early close and cancelled close with a worker.

Refs #89
why: Group members can retain the PTY after the direct child exits.

what:
- Document group pidfd signaling, its fallback and closed_before_eof.
why: Doctest collection imports the Linux worker on macOS and Windows.
Exiting at module scope aborts pytest before it can run the tests.

what:
- Run the Linux capability probe and worker from the script entry point.
- Exercise import and script exit 77 for Darwin and Windows.

Refs #89
@tony
tony force-pushed the fix/89-pty-group-lifetime branch from 104172e to 0a653e5 Compare December 5, 2026 13:44
@tony
tony changed the base branch from master to fix/81-interrupted-drain December 5, 2026 13:44
@tony
tony changed the base branch from fix/81-interrupted-drain to master December 5, 2026 13:52
@tony
tony merged commit 09c33ea into master Dec 5, 2026
9 checks passed
@tony
tony deleted the fix/89-pty-group-lifetime branch December 5, 2026 20:42

This branch was successfully deployed

1 active deployment
docs — 0a653e5d Deployed Dec 5, 2026 by tony via build (3.14) #426
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant