diff --git a/CHANGELOG.md b/CHANGELOG.md index ac41e08..7e552de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,21 @@ All notable changes to dbbackup will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [3.42.50] - 2026-01-16 "Ctrl+C Signal Handling Fix" + +### Fixed - Proper Ctrl+C/SIGINT Handling in TUI +- **Added tea.InterruptMsg handling** - Bubbletea v1.3+ sends `InterruptMsg` for SIGINT signals + instead of a `KeyMsg` with "ctrl+c", causing cancellation to not work +- **Fixed cluster restore cancellation** - Ctrl+C now properly cancels running restore operations +- **Fixed cluster backup cancellation** - Ctrl+C now properly cancels running backup operations +- **Added interrupt handling to main menu** - Proper cleanup on SIGINT from menu +- **Orphaned process cleanup** - `cleanup.KillOrphanedProcesses()` called on all interrupt paths + +### Changed +- All TUI execution views now handle both `tea.KeyMsg` ("ctrl+c") and `tea.InterruptMsg` +- Context cancellation properly propagates to child processes via `exec.CommandContext` +- No zombie pg_dump/pg_restore/gzip processes left behind on cancellation + ## [3.42.49] - 2026-01-16 "Unified Cluster Backup Progress" ### Added - Unified Progress Display for Cluster Backup diff --git a/bin/README.md b/bin/README.md index 093a64c..317a71c 100644 --- a/bin/README.md +++ b/bin/README.md @@ -3,9 +3,9 @@ This directory contains pre-compiled binaries for the DB Backup Tool across multiple platforms and architectures. ## Build Information -- **Version**: 3.42.48 -- **Build Time**: 2026-01-16_14:32:45_UTC -- **Git Commit**: 780beaa +- **Version**: 3.42.49 +- **Build Time**: 2026-01-16_14:37:18_UTC +- **Git Commit**: bfe99e9 ## Recent Updates (v1.1.0) - ✅ Fixed TUI progress display with line-by-line output diff --git a/internal/tui/backup_exec.go b/internal/tui/backup_exec.go index bb45b6a..6ed2d2a 100644 --- a/internal/tui/backup_exec.go +++ b/internal/tui/backup_exec.go @@ -295,6 +295,20 @@ func (m BackupExecutionModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { } return m, nil + case tea.InterruptMsg: + // Handle Ctrl+C signal (SIGINT) - Bubbletea v1.3+ sends this instead of KeyMsg for ctrl+c + if !m.done && !m.cancelling { + m.cancelling = true + m.status = "[STOP] Cancelling backup... (please wait)" + if m.cancel != nil { + m.cancel() + } + return m, nil + } else if m.done { + return m.parent, tea.Quit + } + return m, nil + case tea.KeyMsg: switch msg.String() { case "ctrl+c", "esc": diff --git a/internal/tui/menu.go b/internal/tui/menu.go index 128c8e2..9988620 100755 --- a/internal/tui/menu.go +++ b/internal/tui/menu.go @@ -188,6 +188,21 @@ func (m *MenuModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { } return m, nil + case tea.InterruptMsg: + // Handle Ctrl+C signal (SIGINT) - Bubbletea v1.3+ sends this + if m.cancel != nil { + m.cancel() + } + + // Clean up any orphaned processes before exit + m.logger.Info("Cleaning up processes before exit (SIGINT)") + if err := cleanup.KillOrphanedProcesses(m.logger); err != nil { + m.logger.Warn("Failed to clean up all processes", "error", err) + } + + m.quitting = true + return m, tea.Quit + case tea.KeyMsg: switch msg.String() { case "ctrl+c", "q": diff --git a/internal/tui/restore_exec.go b/internal/tui/restore_exec.go index 000f0cb..e120151 100755 --- a/internal/tui/restore_exec.go +++ b/internal/tui/restore_exec.go @@ -536,6 +536,21 @@ func (m RestoreExecutionModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { } return m, nil + case tea.InterruptMsg: + // Handle Ctrl+C signal (SIGINT) - Bubbletea v1.3+ sends this instead of KeyMsg for ctrl+c + if !m.done && !m.cancelling { + m.cancelling = true + m.status = "[STOP] Cancelling restore... (please wait)" + m.phase = "Cancelling" + if m.cancel != nil { + m.cancel() + } + return m, nil + } else if m.done { + return m.parent, tea.Quit + } + return m, nil + case tea.KeyMsg: switch msg.String() { case "ctrl+c", "esc": diff --git a/main.go b/main.go index bc0817a..3fcef01 100755 --- a/main.go +++ b/main.go @@ -16,7 +16,7 @@ import ( // Build information (set by ldflags) var ( - version = "3.42.49" + version = "3.42.50" buildTime = "unknown" gitCommit = "unknown" )