Skip to content

fix(signals): Reap requests before manager exit - #14

Merged
mweidle73 merged 5 commits into
masterfrom
codex/interrupt-reaping
Oct 18, 2026
Merged

mweidle73 merged 5 commits into
masterfrom
codex/interrupt-reaping

Conversation

@mweidle73

Copy link
Copy Markdown
Member

Purpose

Prevent catchable manager shutdown from abandoning killed request descendants
before the executor reaps them, including after retirement of the leader's
process-group identity.

Changes

The synchronized shutdown hook closes the fork gate, terminates the pinned
group and waits for the sole executor's reap acknowledgement. A fixed
one-second deadline fail-stops with status 125 if collection cannot finish.
Executor-side containment failures never wait for themselves.

Verification

Rootless Debian Trixie builds, make tests and make doc pass. Direct C
barriers exercise delayed and stalled descendant reaping. A real-manager
subreaper oracle checks both request kinds with SIGINT and SIGTERM,
independently of container init. The original implementation and missing
wait/deadline mutations fail the corresponding assertions. Test recovery
also covers successive adoptions and is bounded.

Compatibility and documentation

The wire format, public API and ordinary request semantics are unchanged.
Existing SIGKILL/OOM and process-group escape limitations still apply.
README, lifecycle guidance and the Unreleased changelog are updated. No
release tag or native performance claim is included.

Co-Authored-By: GPT-6.1 noreply@openai.com

Wait for the sole executor to acknowledge complete request reaping
before catchable shutdown exits the manager. Retain that ownership
after the leader group identity is retired, with a fixed fail-stop
bound if the executor cannot finish.

Keep executor-side fail-stop nonwaiting to avoid awaiting itself.
Do not alter the wire format, request results or ordinary spawn path.

Add delayed/stalled C reap barriers and a built-manager subreaper
oracle for both request kinds and termination signals. The original
manager and missing-wait/deadline mutations fail the new assertions.
Supply Python through the CI image, not runtime package installation.
Bound adopted-child collection in the delayed-reaping fixture and
respect OBJDIR when locating the built manager. Keep completed work
in the changelog instead of the public follow-up queue.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-18T06:05:10.339041Z dc3b3bb PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Cross-task shutdown synchronization needs human validation, and the C regression fixture requires corrected subreaper ownership.

1 open issue
What changed in this PR

Prevents catchable manager shutdown from exiting before the executor finishes reaping request descendants.

Changes:

  • Adds a synchronized reap acknowledgement with a one-second fail-stop deadline.
  • Adds direct C and real-manager shutdown regression checks.
  • Updates lifecycle documentation and Python test dependencies.
File Description
tools/​spawn-signals.adb Clarifies shutdown hook comment.
tests/​spawn-posix-tests.c Tests delayed and stalled reaping.
tests/​check_signal_shutdown.sh Updates shutdown check wording.
tests/​check_signal_reaping.py Adds subreaper-based integration checks.
src/​spawn-posix.h Documents bounded shutdown reaping.
src/​spawn-posix.c Implements executor acknowledgement and deadline.
README.md Documents test dependencies and coverage.
Makefile Runs signal-reaping integration checks.
doc/​lifecycle-v1.md Defines shutdown acknowledgement behavior.
CHANGELOG.md Records the shutdown fix.
.github/​ci/​Dockerfile.trixie Installs Python for integration checks.

Review effort: Balanced

Comment thread tests/spawn-posix-tests.c
Enable subreaping in each forked supervisor because Linux does not
inherit that setting, even though the initialization cache is copied.
Require no adopted child after normal completion and outer recovery
only for the deliberately stalled fail-stop.

The rootless Trixie suite passes. Missing supervisor initialization
and false ECHILD after the reap barrier both fail the new assertion.
Removing that assertion makes the skipped-reap mutation pass again.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Cross-task shutdown needs human validation, and the new tests retain unresolved reliability issues.

1 open issue
1 previously missed issue

In code that hasn't changed since last review

Medium severity Use relative socket paths and restore the working directory

tests/​check_signal_reaping.py:103

With a long TMPDIR, the fixture's absolute socket path can exceed Linux's Unix-socket address limit even though the manager binds the short manager.sock address successfully. This raises OSError: AF_UNIX path too long and fails the newly mandatory integration check. Connect relative to the fixture directory, restoring the caller's working directory on both success and failure.

1 resolved since last review

Review effort: Balanced

Comment thread tests/spawn-posix-tests.c Outdated
Enable subreaping in the publication supervisor and wait for actual
descendant metadata before releasing its fork barrier. Reuse bounded
recovery and reject adoption at each test boundary, so one fixture
cannot contaminate the next.

The old test fails natively on ARM64. Both ARM64 and emulated AMD64
reject missing subreaper setup and skipped collection mutations;
corrected direct-core runs pass repeatedly on both. Production code
and the wire contract are unchanged.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Cross-task shutdown synchronization and reap ownership warrant final human review of the reported runtime verification.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

Connect relative to the fixture directory and use contextlib.chdir
to restore the caller directory on every return and exception. The
harness is sequential, so no other cwd consumer can race this scope.

Add real-socket checks for missing, refused, successful and unexpected
error outcomes under an overlong parent path. Absolute-connect and
cwd-leak mutations fail. The Trixie suite passes, including an actual
manager run with a long TMPDIR. Production behavior is unchanged.
@mweidle73

Copy link
Copy Markdown
Member Author

Addressed the long-TMPDIR note from review 5562067112 in 2ceed04. The sequential client now connects with only the socket basename inside contextlib.chdir, restoring the caller directory on both returns and exceptions.

A mandatory real-socket self-check independently proves that its absolute address exceeds the limit and checks missing, refused, successful and unexpected-error outcomes. Absolute-connect and three cwd-leak mutations fail their specific assertions. Both protocol stacks pass full rootless Trixie tests and the actual-manager shell/exec SIGINT/SIGTERM matrix with a long TMPDIR. The socket self-check also passes natively on ARM64. Only test source changed; production and wire behavior are unchanged.

PR #15 is restacked without changing its three V2 patches. Hosted checks are rerunning on both updated heads.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Cross-task shutdown synchronization and fail-stop reaping require final human validation.

No open issues 🎉

Review effort: Balanced

@mweidle73
mweidle73 merged commit 919ec0c into master Oct 18, 2026
4 checks passed
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.

2 participants