Repository navigation
Fix GUI freeze on terminal suspend signals - #117
Conversation
|
i tested this out on my system too and |
| // 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) |
There was a problem hiding this comment.
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
}| return func() { | ||
| close(done) | ||
| signal.Stop(ch) | ||
| signal.Reset(syscall.SIGTSTP) |
There was a problem hiding this comment.
then you can remove this as well
| select { | ||
| case _, ok := <-ch: | ||
| if !ok { | ||
| return |
There was a problem hiding this comment.
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.
1ce3f23 to
522b25e
Compare
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]>
722f0f2 to
49efac1
Compare
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
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,SIGHUPpublish the same quit event used by window close, so the app exits through the normal handler chain and deferred closes terminate extension processesSIGTSTPis ignored: a stopped GUI client cannot answer the compositor's close requests, which is what produced the zombie windowImplementation Details
watchGUISignals(newsignals_unix.go,!windowstag) registers the handlers and returns a cleanup func; wired as a deferred call inrunGUIafterattachGUIsopublishEventcan deliverquitEvent(appMenuKeyBindings(cfg))path — identical to the window ✕ / Quit menu — soErrHandlerExitedrunsg.Close()/root.Close()/runner.Close()and extensions die cleanly instead of orphaningsyscall.Kill(getpid(), SIGTERM)asserts the quit event is published;SIGTSTPasserts the signal is ignored (checkingSigIgnin/proc/self/statuson Linux) instead of stopping the test processVerification
go test -race ./cmd/rune/— green, including both new tests./bin/rune -Gfrom a shell in a real pty — before this changeCtrl+Zput the process inTlstate with a frozen uncloseable window; after, the process staysSl+and responsive, andSuper+W/ ✕ close it normallykill -TERMon the running GUI exits through the quit path (default disposition is bypassed oncesignal.Notifyis registered)One follow-up noted but out of scope: children orphaned by uncatchable kills (
SIGKILL, stop→kill) would need a stdin-EOF watchdog inrune-go-sdk's serve loop — happy to file that separately.Fixes #100