Skip to content

Serialize signal receipt with foreground child admission - #4596

Merged
max-sixty merged 2 commits into
mainfrom
codex/startup-signal-owner
Oct 26, 2026
Merged

max-sixty merged 2 commits into
mainfrom
codex/startup-signal-owner

Conversation

@max-sixty

@max-sixty max-sixty commented Oct 26, 2026 •

Copy link
Copy Markdown
Owner

Ctrl-C during concurrent hook startup could leave wt waiting forever after an existing child finished cleanup. If the kernel assigned SIGINT to another thread and delayed its handler, the spawning thread could admit children that missed both the terminal signal and the cancellation checks.

Initialize one Unix thread that owns signal receipt and process creation. Other threads inherit blocked SIGINT/SIGTERM; the owner and its children retain the inherited mask. Run foreground admission checks on that owner, preserving cleanup for previously admitted children. Child execution and waits remain concurrent. Library callers that omit early startup initialization retain their existing direct-spawn behavior.

Reproduced the failure on both the reported revision and current main by pausing native SIGINT delivery with Linux ptrace: late shell children survived after CLEANUP_FINISHED, and wt timed out waiting for them. Under the repair, the same pause admitted no additional children and the command exited with 130 after cleanup. This reproduces the reported failure mode; the original CI log alone cannot establish its precise scheduling history.

Validation:

  • Linux project validation: 5,476 tests, pre-commit/Clippy, lockfile, docs, and doctests (one configured skipped test). Two process-group tests required rerunning unchanged with Docker --init so orphaned children were reaped.
  • Regression test delays signal handling while another thread attempts admission; it also checks child masks and reusable commands. Bypassing owner routing makes it fail with “child started before signal receipt finished”; restoring the repair passes.
  • Native spawn tests cover in-flight TERM cancellation, cancellation overriding an exec failure, and recovery after an owner request panics; both affected tests pass on macOS.
  • Linux foreground suite: 82 passed, including real bash, zsh, fish, and Nushell jobs.
  • Paired Linux wt list timing: baseline median 21.36 ms, repair 21.28 ms over 20 alternating samples each (nine worktrees, four dirty).

Closes #4511.

This was written by Codex on behalf of max-sixty

worktrunk-bot
worktrunk-bot previously approved these changes Oct 26, 2026
@worktrunk-bot
worktrunk-bot dismissed their stale review October 26, 2026 06:39

Codecov patch check failed: 17 uncovered added lines; AGENTS.md requires this merge gate to pass or explicit approval.

@worktrunk-bot

Copy link
Copy Markdown
Collaborator

The codecov/patch check failed on this commit: 202 of 219 added executable lines were covered (92.23%). The 17 misses include the new process owner error paths and foreground admission branches. This repository treats that check as a merge gate, so I dismissed my approval. The coverage gap needs to be addressed, or a maintainer needs to explicitly accept it before merging.

@max-sixty
max-sixty merged commit 057037a into main Oct 26, 2026
38 checks passed
@max-sixty
max-sixty deleted the codex/startup-signal-owner branch October 26, 2026 07:47
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.

ci-fix: nightly failing — foreground startup-interrupt test hangs waiting for wt to exit

2 participants