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()