Skip to content

Close the host on SIGINT, SIGTERM, and SIGHUP (core-signals) - #1702

Closed
kblok wants to merge 7 commits into
mainfrom
fix/1677-core-signals-port
Closed

kblok wants to merge 7 commits into
mainfrom
fix/1677-core-signals-port

Conversation

@kblok

@kblok kblok commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

Closes #1677

Ports upstream e2e-inc/e2e#1734 core/signals.ts: LaunchOptions.HandleSignals (default true), Signals.CloseOnSignals, and core-signals.test.ts as CoreSignals/CoreOnASignalTests. Resumes closed #1694, merged with current main.

Upstream parity

  • Ported: handleSignals, close of every opted-in host on SIGINT/SIGTERM/SIGHUP, re-raise unless the program listens itself, stderr message on a failed close. Docs, SKILL.md, host.md and COMPATIBILITY updated.
  • Tests: 'closes the host, disposing its engine, then ends by the signal' and 'says on stderr that a close failed, and still ends by the signal' ported whole. 'ends by SIGHUP though the engine listens for it...' is Partial_: .NET cannot enumerate PosixSignalRegistrations, so the engine-listener removal is not asserted. Tracked in Core signals: engine-owned signal listeners (engineListeners, upstream #1734) #1701 (replaces Core signals: engine-owned signal listeners (engineListeners, upstream #1734) #1693, closed not planned).
  • Port-only: libc kill/signal P/Invokes (needed to re-raise a signal in .NET), and the rollback of a failed registration.
  • Verdict: complete, with the justified partial above.

Local check: CoreSignals 3/3 pass on net10.0 (the sandbox has no .NET 11 SDK).


Generated by Claude Code

Summary by CodeRabbit

  • New Features

    • Hosts now close when they receive SIGINT, SIGTERM, or SIGHUP. Signal handling is enabled by default and can be disabled through launch options.
    • After closing, the program continues its normal signal-based exit behavior. Close failures are reported to standard error.
  • Documentation

    • Updated compatibility and launch guides with signal-handling behavior, platform limitations, and artifact storage details.

… #1734)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ls2e21jov6Swn2Aj93SnF7
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ls2e21jov6Swn2Aj93SnF7
… alone, update stale docs

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ls2e21jov6Swn2Aj93SnF7
… signal, mark the second signal test partial

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ls2e21jov6Swn2Aj93SnF7
@coderabbitai

coderabbitai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Caution

Review failed

The pull request is closed.

Walkthrough

Launch options now enable host closure on SIGINT, SIGTERM, and SIGHUP by default. Signal handling closes registered hosts, reports close failures, and then applies platform-specific signal behavior. Integration tests and documentation cover this behavior and its limitations.

Changes: Host Signal Handling

Layer / File(s) Summary
Launch option and host registration
src/E2E/Core/Launch.cs, docs-site/src/content/docs/api/E2E/LaunchOptions.md, docs-site/src/content/docs/docs/core.mdx, skills/e2e-dotnet/*, COMPATIBILITY.md
LaunchOptions.HandleSignals defaults to true. Launch registers signal-driven host closure when enabled, and host shutdown unregisters the handler. The documentation describes the option, signal behavior, platform differences, and porting limitations.
Signal dispatch and host shutdown
src/E2E/Core/Signals.cs
Signals registers callbacks for supported signals, closes registered hosts, reports close failures to stderr, and re-raises signals with platform-specific fallbacks.
Signal integration test harness and coverage
tests/E2E.Tests.App/*, tests/E2E.Tests/CoreSignals/*
The test app adds a signal-host mode and fake engine session. Non-Windows integration tests cover host disposal, signal exit behavior, self-listening behavior, and close-failure output.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant Process
  participant Signals
  participant Host
  participant Session
  Process->>Signals: Deliver SIGINT, SIGTERM, or SIGHUP
  Signals->>Host: Invoke registered close callback
  Host->>Session: Dispose during shutdown
  Signals->>Process: Re-raise signal or use platform exit behavior
Loading

Possibly related issues

Possibly related PRs

Merge Risk: Moderate · up to 243ec

Signal-driven host cleanup can be cut short when a Windows console is closed, and a late-cancelling program signal listener can be overridden so the process ends anyway. The signal tests also cannot fully prove the process ended by the signal. Fix or accept these before merging; setting HandleSignals=false avoids the behavior.

- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

…o signal can be registered

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ls2e22ty6x1BTtW9RcfMkd

kblok commented Nov 16, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review


Generated by Claude Code

@coderabbitai

coderabbitai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor
Action not completed

Pull request is closed.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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.

Core: close the host on SIGINT, SIGTERM, and SIGHUP (core-signals, upstream #1734)

2 participants