Repository navigation
linux system adapter: InstallShutdownHook for SIGTERM/SIGINT - #128
Merged
Merged
Conversation
turinglambdaai
force-pushed
the
feat/linux-shutdown-hook
branch
3 times, most recently
from
October 8, 2026 02:06
f6e43da to
2f6208a
Compare
First-party shutdown plumbing for #120: embedded Racket CS installs its own signal handlers, so a staged host absorbs SIGTERM and exit-time state flushing never runs on OS logout, launchd kills, or plain `kill <pid>`. InstallShutdownHook(callback) installs a SIGTERM/SIGINT handler that is async-signal-safe (one write into a self-pipe); a watcher thread runs the callback on a normal stack — file writes and other state flushing are allowed there — and exits with status 0. A second signal restores the default disposition so operators can still hard-kill a stuck shutdown. pipe2(O_CLOEXEC) with a non-blocking read end; falls back to pipe()+fcntl where pipe2 is unavailable. macOS/WinRT get the equivalent surfaces in follow-ups; the pattern matches RivetSystem's crash-hook contract.
turinglambdaai
force-pushed
the
feat/linux-shutdown-hook
branch
from
October 8, 2026 07:05
2f6208a to
b7ac6c2
Compare
This was referenced Oct 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
First Linux adapter slice of #120.
The embedded Racket CS runtime installs its own signal handlers, so a staged Linux host can absorb SIGTERM: state flushing on container stops, session shutdown, and
kill <pid>is then bypassed.rivet::system::InstallShutdownHook(callback)gives hosts one safe opt-in shutdown boundary:errno;EAGAINfor shutdown;_Exitto avoid static-destruction races;pipe2(O_CLOEXEC)and checkedfcntlsetup prevent descriptor inheritance and signal-handler deadlock;InstallCrashHook.The Linux embedded-roundtrip workflow now launches a real probe process, proves it stays alive before SIGTERM, verifies the callback marker, and requires a clean zero-status exit within five seconds.
Hosts still opt in by calling the hook early on the main thread. Scaffold wiring and the macOS/Windows equivalents remain follow-up work, so #120 stays open.