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 <noreply@anthropic.com>
This commit is contained in:
vrubelroman 2026-11-01 09:07:29 +03:00
parent 166116e57a
commit 0059d26b3b
3 changed files with 11 additions and 5 deletions

2
.gitignore vendored
View file

@ -1,5 +1,5 @@
target/
vcom
/vcom
# release artifacts
*.tar.gz

View file

@ -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 {

View file

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