Add comprehensive process cleanup on TUI exit
- Created internal/cleanup package for orphaned process management - KillOrphanedProcesses(): Finds and kills pg_dump, pg_restore, gzip, pigz - killProcessGroup(): Kills entire process groups (handles pipelines) - Pass parent context through all TUI operations (backup/restore inherit cancellation) - Menu cancel now kills all child processes before exit - Fixed context chain: menu.ctx → backup/restore operations - No more zombie processes when user quits TUI mid-operation Context chain: - signal.NotifyContext in main.go → menu.ctx - menu.ctx → backup_exec.ctx, restore_exec.ctx - Child contexts inherit cancellation via context.WithTimeout(parentCtx) - All exec.CommandContext use proper parent context Prevents: Orphaned pg_dump/pg_restore eating CPU/disk after TUI quit
This commit is contained in:
@@ -65,7 +65,7 @@ func (m InputModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
// If this is from database selector, execute backup with ratio
|
||||
if selector, ok := m.parent.(DatabaseSelectorModel); ok {
|
||||
ratio, _ := strconv.Atoi(m.value)
|
||||
executor := NewBackupExecution(selector.config, selector.logger, selector.parent,
|
||||
executor := NewBackupExecution(selector.config, selector.logger, selector.parent, selector.ctx,
|
||||
selector.backupType, selector.selected, ratio)
|
||||
return executor, executor.Init()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user