From 0059d26b3bf5bd29d868e53483e4507cb10919c9 Mon Sep 17 00:00:00 2001 From: vrubelroman Date: Sun, 1 Nov 2026 09:07:29 +0300 Subject: [PATCH] fix: do not subscribe to SIGTERM next to Bubble Tea (QA-12) Both main and Bubble Tea handled SIGTERM. When main's tea.Quit won the race, Bubble Tea's signal goroutine blocked forever on an unbuffered send and Program.shutdown waited for it: vcom hung in the alt screen without saving the session. Bubble Tea already handles SIGTERM/SIGINT; main now only adds SIGHUP. Also: .gitignore 'vcom' ignored the whole cmd/vcom/ dir, anchor it to the binary (/vcom); the SIGTERM pty test runs 2 iterations by default and the full 12 with VCOM_SLOW_TESTS=1. Co-Authored-By: Claude Opus 5.5 --- .gitignore | 2 +- cmd/vcom/main.go | 6 ++++-- cmd/vcom/qa_signal_test.go | 8 ++++++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 3985ca4..032517b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ target/ -vcom +/vcom # release artifacts *.tar.gz diff --git a/cmd/vcom/main.go b/cmd/vcom/main.go index 8001383..297aea3 100644 --- a/cmd/vcom/main.go +++ b/cmd/vcom/main.go @@ -79,9 +79,11 @@ func run() int { program := tea.NewProgram(model, tea.WithAltScreen(), tea.WithMouseCellMotion()) // SIGTERM/SIGINT are handled by Bubble Tea itself; SIGHUP (terminal - // closed) is not. Either way the program quits and teardown runs below. + // closed) is not. Do NOT subscribe to SIGTERM here: when our tea.Quit + // wins the race, Bubble Tea's own signal goroutine blocks forever on an + // unbuffered send and Program.shutdown waits for it (QA-12). sigs := make(chan os.Signal, 1) - signal.Notify(sigs, syscall.SIGHUP, syscall.SIGTERM) + signal.Notify(sigs, syscall.SIGHUP) defer signal.Stop(sigs) go func() { for s := range sigs { diff --git a/cmd/vcom/qa_signal_test.go b/cmd/vcom/qa_signal_test.go index 055e0f8..d65ca72 100644 --- a/cmd/vcom/qa_signal_test.go +++ b/cmd/vcom/qa_signal_test.go @@ -30,7 +30,6 @@ func TestQASigtermHelperProcess(t *testing.T) { } func TestQASigtermExitsAndSavesSession(t *testing.T) { - t.Skip("BUG QA-12 (P1, regression from 2C): SIGTERM sometimes hangs vcom forever: main.go:83-92 subscribes to SIGTERM in addition to Bubble Tea; if main's tea.Quit wins, Bubble Tea's signal goroutine blocks on p.msgs <- QuitMsg{} and Program.shutdown waits for it (vendor bubbletea tea.go:302, :814); terminal stays in alt screen, session not saved") script, err := exec.LookPath("script") if err != nil { t.Skip("util-linux script not available") @@ -39,7 +38,12 @@ func TestQASigtermExitsAndSavesSession(t *testing.T) { if err != nil { t.Fatal(err) } - const runs = 12 + // The hang was intermittent (~1 in 3); 12 runs take ~80s, so CI does a + // quick 2-run smoke and VCOM_SLOW_TESTS=1 enables the full loop. + runs := 2 + if os.Getenv("VCOM_SLOW_TESTS") != "" { + runs = 12 + } hung, saved := 0, 0 for i := 0; i < runs; i++ { home := t.TempDir()