Skip to content

Reap active Git and GitHub subprocesses on SIGTERM - #1290

Merged
mergify[bot] merged 2 commits into
mainfrom
lean178/1178-sigterm-unwind-v3
Nov 26, 2026
Merged

mergify[bot] merged 2 commits into
mainfrom
lean178/1178-sigterm-unwind-v3

Conversation

@eowca

@eowca eowca commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Context and goal

  • Context: Loop-zero runs Git and GitHub commands in separate process groups.
  • Problem: Status can exit on SIGTERM while the GitHub child keeps running.
  • Goal: Unwind through subprocess cleanup before exiting on SIGTERM.

Closes #1178

Acceptance

  • SIGTERM during a real supervised GitHub subprocess stops the child and retains the CLI's signal exit.
  • SIGINT stops the child and retains exit 130.
  • Direct check and native review callers retain private-directory signal cleanup.

Supersedes #1262. The fresh regression also delivers SIGTERM during handler restoration. Both the supervisor and CLI signal tests pass, and source line count stays within the current budget.


Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

Review

  • primary, claude, 1c765be, approve

Validation

Recorded for 1c765bed1821

  • uv run --group dev ruff check src tests: exit 0
  • uv run --group dev tach check: exit 0
  • uv run --python 3.14 python scripts/check_architecture_docs.py: exit 0
  • scripts/size_budget.sh: exit 0
  • uv run --group dev pytest -q: exit 0

Architecture-Review: unchanged; CLI dispatch shares the existing signal handler and preserves termination during late signal delivery.
Co-Authored-By: Codex <noreply@openai.com>
@eowca
eowca marked this pull request as draft November 26, 2026 01:23

@loopzero-feder-positronics loopzero-feder-positronics Bot 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.

loopzero primary review by claude on 1c765bed182110f06318d87de2b8f0b5b42c406a, 39.9s: approve (0 critical, 0 important, 2 suggestion)

Settings per native call (launch configuration and CLI claims, not backend attestation):

  • Call 1: requested model claude-opus-5-5 (effort medium); CLI-reported model claude-opus-5-5 (effort unknown); configured model claude-opus-5-5 (effort medium)

Native Claude output is retained in the restricted local review receipt.

Comment thread src/loopzero/_proc.py


def _request_unwind(_signum, _frame):
signal.signal(signal.SIGTERM, signal.SIG_IGN)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion: Unwind-time children inherit SIGTERM=SIG_IGN, now across the whole CLI

_request_unwind sets SIGTERM to SIG_IGN until unwind_on_sigterm exits. Popen(restore_signals=True) only resets SIGPIPE, SIGXFZ and SIGXFSZ. So any subprocess started from a finally/cleanup path while Terminated is propagating keeps ignoring SIGTERM after exec. This already happened inside sandbox scopes. Because cli.main now wraps every command, it can affect any cleanup that runs Git or gh. Impact is small: those children are short-lived and _proc.run SIGKILLs on exceptions. Smallest fix: block SIGTERM with signal.pthread_sigmask instead of using SIG_IGN, or pass a preexec_fn/process_group reset in _proc.run. At minimum, add a comment documenting it.

Comment thread src/loopzero/_proc.py
except subprocess.TimeoutExpired as exc:
out = exc.stdout.decode(errors="replace") if isinstance(exc.stdout, bytes) else exc.stdout
out = out or ""
out = exc.stdout.decode(errors="replace") if isinstance(exc.stdout, bytes) else (exc.stdout or "")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion: Unrelated TimeoutExpired refactor

This change folds out = out or "" into the conditional expression. It is behavior-neutral but unrelated to SIGTERM unwinding, and the new line is longer than the surrounding style. Revert it to keep the diff focused.

@eowca
eowca marked this pull request as ready for review November 26, 2026 01:41
@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

@Mergifyio queue

@mergify

mergify Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

❌ Left the queue · checks failed

2 min in the queue, with no time running CI.

So far

  • ✅ Entered the queue Thu 26 Nov, 01:42 · rule main · triggered by @eowca with the @mergifyio queue command
  • ❌ Checks failed · draft #1329
  • 🚫 Left the queue 01:44 · 1c765be

Not proven to be this pull request's failure. It failed on top of the pull requests ahead of it, and was not tested alone.

Reason

The merge conditions cannot be satisfied due to failing checks

  • checks

Failing checks:

To get back in the queue

  • If the failure comes from the pull requests it was tested with, or is a flake, comment @mergifyio queue to queue it again as it is.
  • If it is this pull request's, push a fix: the pull request is queued again once its queue conditions match.

Merge conditions not met when it left the queue

  • any of · required by GitHub repository ruleset rule main: PR only, Mergify queue, existing checks required:
    • check-neutral = checks
    • check-skipped = checks
    • check-success = checks
  • any of · required by GitHub repository ruleset rule main: PR only, Mergify queue, existing checks required:
    • check-neutral = Loop-zero Eligibility
    • check-skipped = Loop-zero Eligibility
    • check-success = Loop-zero Eligibility
1 merge condition met
  • github-review-approved · required by GitHub repository ruleset rule main: PR only, Mergify queue, existing checks required

Times in UTC · dashboard · how the merge queue works

@mergify mergify Bot added the queued label Nov 26, 2026
@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

No description provided.

@mergify mergify Bot removed the dequeued label Nov 26, 2026
@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

Owner queue route. The full sandboxed check passed on 841884cc after a clean merge of main. The remote receipt is missing its settings fingerprint, so the local guard rejected it. Both required hosted checks are green and GitHub accepted the inherited approval. Mergify will verify the integration candidate.

@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

@Mergifyio queue

@mergify

mergify Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

✅ Merged into main as 75de7f1 at 02:43 UTC

10 min in the queue, 4 min of it CI.

So far

  • ✅ Entered the queue Thu 26 Nov, 02:33 · rule main · triggered by @eowca with the @mergifyio queue command
  • ✅ Passed · draft #1411
  • ✅ Merged 02:43 · 75de7f1 · squash
3 merge conditions met
  • github-review-approved · required by GitHub repository ruleset rule main: PR only, Mergify queue, existing checks required
  • any of · required by GitHub repository ruleset rule main: PR only, Mergify queue, existing checks required:
    • check-success = checks
    • check-neutral = checks
    • check-skipped = checks
  • any of · required by GitHub repository ruleset rule main: PR only, Mergify queue, existing checks required:
    • check-success = Loop-zero Eligibility
    • check-neutral = Loop-zero Eligibility
    • check-skipped = Loop-zero Eligibility

Times in UTC · dashboard · how the merge queue works

@mergify mergify Bot added the queued label Nov 26, 2026
@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

No description provided.

@mergify
mergify Bot merged commit 75de7f1 into main Nov 26, 2026
7 checks passed
@mergify mergify Bot removed the queued label Nov 26, 2026
@eowca
eowca deleted the lean178/1178-sigterm-unwind-v3 branch November 26, 2026 02:45
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.

Reap active Git and GitHub subprocesses when loopzero receives SIGTERM

1 participant