Skip to content

feat(pty): expose child pid on ChildHandle for process-group reaping#529

Closed
fengmk2 wants to merge 1 commit into
mainfrom
snap-pty-pgroup-pid
Closed

feat(pty): expose child pid on ChildHandle for process-group reaping#529
fengmk2 wants to merge 1 commit into
mainfrom
snap-pty-pgroup-pid

Conversation

@fengmk2

@fengmk2 fengmk2 commented Jul 9, 2026

Copy link
Copy Markdown
Member

Expose the child PID on ChildHandle so callers can signal the child's whole process group.

Why

The process spawned into a PTY is a session / process-group leader (portable-pty setsids it), but ChildHandle only exposed a single-process killer. A caller that needs to reap grandchildren the command left behind, e.g. a managed-runtime or package-manager helper that inherited the PTY slave fd and keeps the master from ever reaching EOF, had no way to target the group.

What

Add ChildHandle::pid() -> Option<u32>, captured at spawn. Additive; no behavior change for existing callers.

Consumer

vite-plus's PTY snapshot suite: once a step's command exits, it killpgs the group so a lingering grandchild can't wedge the exit-wait (read_to_end, which only returns at PTY EOF) on the Namespace Linux runner (macOS reaps fast enough to hit EOF).

The process spawned into a PTY is a session / process-group leader
(portable-pty setsid's it), but ChildHandle only exposed a single-process
killer. Expose the pid so callers can signal the whole group
(`kill(-pid, ...)` on Unix) to reap grandchildren that inherited the slave
fd and would otherwise keep the PTY master from ever reaching EOF, hanging
`read_to_end`.

fengmk2 commented Jul 9, 2026

Copy link
Copy Markdown
Member Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@fengmk2

fengmk2 commented Jul 9, 2026

Copy link
Copy Markdown
Member Author

Not needed after all: instead of reaping the process group to work around the wedge, vite-plus moves its Linux PTY snapshot leg off the Namespace runner to GitHub-hosted ubuntu-latest (the Namespace Linux runner is where vp processes don't exit; macOS Namespace and GitHub Windows run the same suite clean). Closing; can reopen if a caller needs the group reap later.

@fengmk2 fengmk2 closed this Jul 9, 2026
@fengmk2
fengmk2 deleted the snap-pty-pgroup-pid branch July 9, 2026 11:25
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