refactor(process): Improve subprocess signaling and lifecycle management - #6
Merged
ChristianPraiss merged 1 commit intoJul 28, 2026
Conversation
Implements `runWithSignalForwarding` across exec, main, and TUI components. This enhances graceful shutdown by attempting SIGINT on the first interrupt (Ctrl+C), followed by a hard kill() for subsequent signals, aligning with standard shell conventions. The pattern is extended to manage subprocess lifecycles within the TUI component gracefully.
ChristianPraiss
deleted the
refactor/implement-advanced-signal-forwarding-for-subprocesses
branch
July 28, 2026 13:54
There was a problem hiding this comment.
Pull request overview
Refactors subprocess execution to improve shutdown behavior by introducing centralized signal-handling logic and extending “graceful then force” termination semantics to the TUI’s panel subprocess lifecycle.
Changes:
- Replaces direct
cmd.Run()usage with a sharedrunWithSignalForwarding()helper for consistent SIGINT/SIGTERM handling and escalation behavior. - Enhances the TUI quit flow to first request graceful termination of running panels, then force-kill on repeated quit.
- Tracks per-panel subprocess handles so the TUI can signal them on exit instead of leaving them running.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| tui.go | Adds panel process tracking and a two-phase quit flow (graceful interrupt, then force kill) with updated status bar messaging. |
| main.go | Switches the fallback docker compose <command> execution path to use runWithSignalForwarding(). |
| exec.go | Introduces runWithSignalForwarding() and applies it to subprocess execution paths (scripts and exec). |
Comments suppressed due to low confidence (1)
exec.go:130
- Forwarding SIGINT to cmd.Process here can double-deliver Ctrl+C to the child on Unix, because SIGINT is already sent by the terminal to the entire foreground process group (parent + child). Since we’re not creating a separate process group for cmd (no SysProcAttr.Setpgid usage in the repo), this means a single Ctrl+C can be seen twice by the child, defeating the intended “one Ctrl+C = graceful” behavior.
case sig := <-sigCh:
if !forwarded {
forwarded = true
_ = cmd.Process.Signal(sig)
} else {
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+112
to
+115
| func runWithSignalForwarding(cmd *exec.Cmd) error { | ||
| sigCh := make(chan os.Signal, 1) | ||
| signal.Notify(sigCh, syscall.SIGINT, syscall.SIGTERM) | ||
| defer signal.Stop(sigCh) |
Comment on lines
243
to
+247
| case "q", "Q", "ctrl+c": | ||
| if m.running == 0 { | ||
| return m, tea.Quit | ||
| } | ||
| if !m.stopping { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
⚙️ Refactor(process): Improve Subprocess Signaling and Lifecycle Management
This pull request refactors how subprocesses are executed across key components (
exec,main, and TUI) by implementing standardized, advanced signal forwarding logic.✨ Motivation
Currently, graceful handling of signals upon process shutdown could be inconsistent. This change aims to align the component's behavior more closely with standard shell conventions for subprocess termination, ensuring a reliable user experience even when interrupts (like Ctrl+C) are issued.
🚀 Changes Implemented
The core change is the introduction and usage of
runWithSignalForwarding. This function:kill()) for robust resource cleanup.tui.go) to manage the dedicated lifecycle of panels and subprocesses consistently.Technical Details:
✅ Verification & Testing
Please verify the following:
kill().📚 Review Notes