Skip to content

Fix GUI freeze on terminal suspend signals - #117

Merged
ernestrc merged 2 commits into
unstablebuild:mainfrom
JoeJoeflyn:fix/gui-terminal-signals
Sep 22, 2026
Merged

ernestrc merged 2 commits into
unstablebuild:mainfrom
JoeJoeflyn:fix/gui-terminal-signals

Conversation

@JoeJoeflyn

@JoeJoeflyn JoeJoeflyn commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

GUI mode installed no signal handler, so stopping the process from the launcher terminal (Ctrl+Z, or closing the terminal) left a permanently frozen, uncloseable window on the desktop, and killed runs orphaned extension child processes. This adds a small GUI-mode signal watcher:

  • SIGINT, SIGTERM, SIGHUP publish the same quit event used by window close, so the app exits through the normal handler chain and deferred closes terminate extension processes
  • SIGTSTP is ignored: a stopped GUI client cannot answer the compositor's close requests, which is what produced the zombie window

Implementation Details

  • watchGUISignals (new signals_unix.go, !windows tag) registers the handlers and returns a cleanup func; wired as a deferred call in runGUI after attachGUI so publishEvent can deliver
  • Terminate signals reuse the existing quitEvent(appMenuKeyBindings(cfg)) path — identical to the window ✕ / Quit menu — so ErrHandlerExited runs g.Close() / root.Close() / runner.Close() and extensions die cleanly instead of orphaning
  • Windows stub is a no-op: no POSIX job-control signals exist there
  • Tests drive the real path: syscall.Kill(getpid(), SIGTERM) asserts the quit event is published; SIGTSTP asserts the signal is ignored (checking SigIgn in /proc/self/status on Linux) instead of stopping the test process

Verification

  • go test -race ./cmd/rune/ — green, including both new tests
  • Manual repro of the issue steps on Linux/Wayland: launched ./bin/rune -G from a shell in a real pty — before this change Ctrl+Z put the process in Tl state with a frozen uncloseable window; after, the process stays Sl+ and responsive, and Super+W / ✕ close it normally
  • kill -TERM on the running GUI exits through the quit path (default disposition is bypassed once signal.Notify is registered)

One follow-up noted but out of scope: children orphaned by uncatchable kills (SIGKILL, stop→kill) would need a stdin-EOF watchdog in rune-go-sdk's serve loop — happy to file that separately.

Fixes #100

screenrecording-2026-09-19_00-30-12

@Spandan-Mishra

Copy link
Copy Markdown
Contributor

i tested this out on my system too and Ctrl+Z & Ctrl+C in the terminal work as expected 👍

Comment thread cmd/rune/signals_unix.go Outdated
// ignored instead: a stopped client cannot answer the compositor's
// close requests, leaving a frozen window.
func watchGUISignals(publish func(term.Event) bool, quit term.Event) func() {
signal.Ignore(syscall.SIGTSTP)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this also forces child processes to ignore SIGSTP. Instead of doing it here, why not listen for it below, then ignore it just for this process:

  if sig == syscall.SIGTSTP {
        continue
    }

Comment thread cmd/rune/signals_unix.go Outdated
return func() {
close(done)
signal.Stop(ch)
signal.Reset(syscall.SIGTSTP)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

then you can remove this as well

Comment thread cmd/rune/signals_unix.go
select {
case _, ok := <-ch:
if !ok {
return

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

publish(quit) calls GUI.PublishEvent, which is a non-blocking send that returns false when updateChan is full (unlikely but not impossible). Then the result is discarded, so a signal i.e.SIGTERM arriving while the event queue is saturated is silently lost and the process never exits.

Consider tracking that a terminate signal was already seen, and on a second signal (or if publish returns false) escalate to an immediate exit.

@JoeJoeflyn
JoeJoeflyn force-pushed the fix/gui-terminal-signals branch from 1ce3f23 to 522b25e Compare September 21, 2026 11:11
GUI mode installed no signal handler, so Ctrl+Z in the launcher
terminal stopped the process and left a frozen window the compositor
could not close, while SIGINT/SIGTERM/SIGHUP killed the process
outright and orphaned extension children. Route terminate signals
through the same quit event used by window close so deferred cleanup
terminates extensions. SIGTSTP is caught and dropped rather than
ignored: SIG_IGN survives execve and would leak into child processes
such as integrated-terminal shells. A second terminate signal or a
rejected quit event escalates to os.Exit so a saturated event queue
cannot swallow SIGTERM.

Fixes unstablebuild#100

Signed-off-by: JoeJoeflyn <[email protected]>
@JoeJoeflyn
JoeJoeflyn force-pushed the fix/gui-terminal-signals branch from 722f0f2 to 49efac1 Compare September 21, 2026 19:35
@codecov

codecov Bot commented Sep 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.00000% with 6 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cmd/rune/signals_unix.go 81.81% 2 Missing and 2 partials ⚠️
cmd/rune/main.go 0.00% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@ernestrc
ernestrc enabled auto-merge (squash) September 22, 2026 09:56
@ernestrc
ernestrc merged commit 3c8de1f into unstablebuild:main Sep 22, 2026
8 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.

Rune GUI window freezes and becomes uncloseable when terminal process is stopped/suspended

3 participants