Skip to content

fix: let the Codex session exit on stdin EOF before killing its tree - #905

Open
bandzalkin wants to merge 2 commits into
mainfrom
fix/codex-session-exit-on-eof-before-tree-kill-INT-1897
Open

bandzalkin wants to merge 2 commits into
mainfrom
fix/codex-session-exit-on-eof-before-tree-kill-INT-1897

Conversation

@bandzalkin

Copy link
Copy Markdown
Contributor

Why

CodexStdioClient.close kills the child's whole session with SIGKILL before closing stdin, so Codex never gets the EOF it exits on and nothing it does at shutdown (flushing state, ending the servers it started) can happen. A host that treats the harness's own shutdown as part of its contract, like band-agent's runner, which ends what the harness leaves behind, sees the harness vanish under it instead.

What

Close stdin first and give every process in the child's session up to one second to exit; the tree kill stays as the fallback for a session that does not. The session id stays reserved while any member lives, so probing the group is exact: a launcher shim whose real CLI child keeps the room directory is still reaped (test_close_reaps_a_worker_when_its_launcher_exits_on_stdin_eof now pins that the launcher sees EOF and its worker is reaped). New test: a harness that exits on EOF ends with status 0, not -9.

Scope

POSIX close path only; the Windows job-object path is unchanged.

…s tree

close() killed the child's session with SIGKILL before closing stdin, so
Codex never saw the EOF it exits on and could do nothing at shutdown.
Stdin now closes first and the session gets one second to end on its
own; the tree kill remains the fallback. The session id stays reserved
while any member lives, so a launcher shim's real CLI child that keeps
the room directory is still reaped.
@linear-code

linear-code Bot commented Oct 21, 2026

Copy link
Copy Markdown

INT-1897

bandzalkin added a commit to bandzalkin/band-sdk-python that referenced this pull request Oct 21, 2026
github-actions Bot pushed a commit to bandzalkin/band-sdk-python that referenced this pull request Oct 21, 2026
github-actions Bot pushed a commit to bandzalkin/band-sdk-python that referenced this pull request Oct 21, 2026
github-actions Bot pushed a commit to bandzalkin/band-sdk-python that referenced this pull request Oct 21, 2026
@bandzalkin
bandzalkin marked this pull request as ready for review October 22, 2026 01:55
github-actions Bot pushed a commit to bandzalkin/band-sdk-python that referenced this pull request Oct 22, 2026
@bandzalkin bandzalkin changed the title fix(codex): let the Codex session exit on stdin EOF before killing its tree fix: let the Codex session exit on stdin EOF before killing its tree Oct 22, 2026
@bandzalkin
bandzalkin marked this pull request as draft October 22, 2026 10:09
@bandzalkin
bandzalkin marked this pull request as ready for review October 22, 2026 10:35

This branch has not been deployed

No deployments
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