Skip to content

Keep children of a TTY-less runner away from the terminal - #27

Merged
DomBlack merged 1 commit into
mainfrom
detach-children-from-terminal
Oct 9, 2026
Merged

DomBlack merged 1 commit into
mainfrom
detach-children-from-terminal

Conversation

@DomBlack

@DomBlack DomBlack commented Oct 9, 2026 •

Copy link
Copy Markdown
Owner

An MCP stack_create in a repo with commit.gpgsign on and an SSH signing key that wasn't loaded into ssh-agent never came back. Capture mode gives git a closed stdin, but ssh-keygen asks for the passphrase on /dev/tty (the controlling terminal), and every child inherits that from whatever terminal the MCP server was started in. So git sat on a prompt nobody could see or answer until someone killed ssh-keygen by hand. gpg's pinentry and git's own credential prompt can do exactly the same.

A runner built without a TTY now starts each child in its own session (setsid), so there is no controlling terminal and opening /dev/tty fails; it also sets GIT_TERMINAL_PROMPT=0 and drops GPG_TTY. The prompt turns into an immediate error the tool can return instead of a hang. The CLI runner with a terminal is untouched, so a passphrase prompt in an ordinary git stack create still works as before.

Copilot AI balanced review requested due to automatic review settings October 9, 2026 16:30
@DomBlack
DomBlack added this pull request to stack #31 October 9, 2026 16:30

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.

🟡 Changes recommended

The central detachment regression test does not exercise detachment on headless CI runners.

1 open finding
What changed in this PR

Prevents non-TTY runners, particularly MCP operations, from hanging on hidden terminal prompts.

Changes:

  • Detaches non-TTY subprocesses into independent Unix sessions.
  • Disables Git terminal prompts and removes GPG_TTY.
  • Adds documentation and regression tests.
File Description
pkg/​exec/​runner.go Applies non-interactive environment and detachment.
pkg/​exec/​runner_test.go Tests prompt environment and terminal isolation.
pkg/​exec/​detach_unix.go Implements Unix session detachment.
pkg/​exec/​detach_other.go Provides a non-Unix no-op.
docs/​architecture.md Documents subprocess terminal isolation.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread pkg/exec/runner_test.go
An MCP stack_create in a repo with commit.gpgsign on and an SSH signing key that wasn't loaded into ssh-agent never came back. Capture mode gives git a closed stdin, but ssh-keygen asks for the passphrase on /dev/tty (the controlling terminal), and every child inherits that from whatever terminal the MCP server was started in. So git sat on a prompt nobody could see or answer until someone killed ssh-keygen by hand. gpg's pinentry and git's own credential prompt can do exactly the same.

A runner built without a TTY now starts each child in its own session (setsid), so there is no controlling terminal and opening /dev/tty fails; it also sets GIT_TERMINAL_PROMPT=0 and drops GPG_TTY. The prompt turns into an immediate error the tool can return instead of a hang. The CLI runner with a terminal is untouched, so a passphrase prompt in an ordinary git stack create still works as before.
Copilot AI balanced review requested due to automatic review settings October 9, 2026 16:59
@DomBlack
DomBlack force-pushed the detach-children-from-terminal branch from 3e285bc to 8c24522 Compare October 9, 2026 16:59

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.

🟢 Approved

The implementation is focused, portable, documented, and adequately tested.

0 open findings

1 resolved since last review

🧠 Review effort: Balanced

@DomBlack
DomBlack merged commit 4e71b4b into main Oct 9, 2026
6 checks passed
@DomBlack
DomBlack deleted the detach-children-from-terminal branch October 9, 2026 17:40
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