Skip to content

fix(signal): Improve signal handling robustness on shutdown - #7

Merged
ChristianPraiss merged 1 commit into
mainfrom
fix/improve-signal-handling
Jul 28, 2026
Merged

fix(signal): Improve signal handling robustness on shutdown#7
ChristianPraiss merged 1 commit into
mainfrom
fix/improve-signal-handling

Conversation

@ChristianPraiss

Copy link
Copy Markdown
Contributor

🧪 Fix: Improve Signal Handling Robustness on Shutdown

Description

This change refactors signal handling across process execution and TUI interactions to significantly improve robustness during application shutdown sequences. The primary goal is to ensure that child processes are managed using graceful termination methods (e.g., SIGINT, SIGTERM) rather than relying on hard kills, improving compatibility with modern container orchestration tools like Docker Compose.

🚀 Changes Implemented

The signal forwarding logic has been enhanced in multiple areas:

  • Process Execution (exec.go): The core runWithSignalForwarding logic is modified to consistently capture and forward all received SIGINT/SIGTERM signals. This prevents the forceful escalation to a hard kill, allowing child processes to execute their designated graceful shutdown routines.
  • TUI Interaction (tui.go): The model now accurately tracks repeated stop attempts. Instead of immediately force-terminating on initial failure, it utilizes an incremental signaling approach before resorting to forceful measures, ensuring better adherence to structured container shutdown signals.

✨ How This Improves Robustness

Previously, certain workflows could result in abrupt process termination when signals were received (especially during resource cleanup or coordinated shutdowns). These changes ensure that the application respects the intended lifecycle provided by tools like docker compose and underlying operating systems, making the entire runtime more stable and predictable.

✅ Checklist

  • Confirmed proper signal forwarding for SIGINT/SIGTERM in multi-process contexts.
  • Updated TUI logic to handle stop attempts gracefully.
  • Verified compatibility with common container shutdown patterns.

Refactors signal forwarding across processes and TUI interactions to ensure graceful shutdowns. In `exec.go`, we now consistently forward SIGINT/SIGTERM signals rather than escalating to a hard kill, respecting child process termination sequences (e.g., docker compose). The `tui.go` model also updates to track repeated stop attempts and utilize incremental signaling before resorting to force termination.
Copilot AI review requested due to automatic review settings July 28, 2026 14:06
@ChristianPraiss
ChristianPraiss merged commit dc9ef97 into main Jul 28, 2026
3 checks passed
@ChristianPraiss
ChristianPraiss deleted the fix/improve-signal-handling branch July 28, 2026 14:08

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors shutdown/signal-handling behavior so the CLI and its TUI remain alive during termination and allow child processes to complete graceful shutdown (especially for Docker Compose workflows), rather than escalating quickly to hard kills.

Changes:

  • Update runWithSignalForwarding to forward repeated SIGINT/SIGTERM signals instead of escalating to SIGKILL internally.
  • Add TUI stop-attempt tracking to forward SIGINT multiple times before force-killing on a final attempt.
  • Improve TUI status bar messaging to reflect remaining stop attempts before forced quit.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
tui.go Adds stopPresses tracking and adjusts quit/stop behavior to forward SIGINT before force-killing on repeated attempts.
exec.go Changes signal-forwarding behavior to forward every received SIGINT/SIGTERM to the child (removing internal escalation to SIGKILL).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread exec.go
Comment on lines 129 to +132
for {
select {
case sig := <-sigCh:
if !forwarded {
forwarded = true
_ = cmd.Process.Signal(sig)
} else {
_ = cmd.Process.Kill()
}
_ = cmd.Process.Signal(sig)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants