Skip to content

linux: terminate on SIGTERM/SIGINT in the host scaffold and example - #168

Merged
turinglambdaai merged 2 commits into
mainfrom
linux/graceful-signal-shutdown
Oct 9, 2026
Merged

turinglambdaai merged 2 commits into
mainfrom
linux/graceful-signal-shutdown

Conversation

@turinglambdaai

Copy link
Copy Markdown
Owner

Problem

Reproduced on Fulcrum 0.4.1 (Ubuntu 26.04, GNOME/Wayland): kill -TERM on a running app broke the embedded Racket backend (Rivet backend terminated: user break) while the GTK process stayed alive. The window remained, every search silently did nothing, and only kill -9 removed it. systemd --user stop, session logout, and killall all send exactly this signal.

Root cause

The Linux system adapter has shipped InstallShutdownHook since #128 with a solid self-pipe + watcher design (covered by --shutdown-probe), but nothing outside the integration probe installs it. The GTK shutdown signal never fires on an OS signal, so the orderly cleanup path is unreachable for terminations.

Change

  • platform/linux/host/src/main.cpp (the scaffold every rivet-new app copies): refactor the GTK shutdown cleanup into perform_orderly_shutdown and install it via InstallShutdownHook in main.
  • examples/taskboard/linux/src/main.cpp: same wiring.
  • Hook installation failure degrades to a stderr note — apps still run, just without signal handling.

Verification

  • Template host builds clean against a local Racket 9.3 CS + GTK4 toolchain.
  • RivetIntegration --shutdown-probe: TERM → callback runs (marker written) → exit code 0.

Apps with their own copies of the scaffold (Fulcrum, SyncPilot) need the same one-liner in their linux/src/main.cpp — follow-ups will land in those repos.

turinglambdaai and others added 2 commits October 9, 2026 21:19
The Linux system adapter has shipped InstallShutdownHook since #128,
but nothing outside the integration probe installed it — and the GTK
shutdown signal never fires on a termination signal. A TERM therefore
broke the embedded Racket backend while the GTK process kept running:
Fulcrum 0.4.1 kept a visible window whose searches silently did
nothing, and only SIGKILL removed it.

Install the hook in the host scaffold and the Taskboard example, running
the same orderly shutdown as the GTK shutdown signal; the watcher thread
hard-exits with EXIT_SUCCESS once it returns.
@turinglambdaai
turinglambdaai merged commit 155c849 into main Oct 9, 2026
15 checks passed
@turinglambdaai
turinglambdaai deleted the linux/graceful-signal-shutdown branch October 9, 2026 15:20
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.

1 participant