Skip to content

Fix the detach hang: one ctrl+c releases the terminal immediately - #8

Merged
gurnben merged 1 commit into
mainfrom
fix/detach-hang
Oct 21, 2026
Merged

gurnben merged 1 commit into
mainfrom
fix/detach-hang

Conversation

@gurnben

@gurnben gurnben commented Oct 21, 2026

Copy link
Copy Markdown
Member

Summary

Detaching held the terminal open until a second ctrl+c. Root cause: the attach monitor's relay goroutine waited for the journal tailer to close its feed channel — but a detached run is still going, so its tailer never stops. The tea program had already exited and restored the terminal, yet the process sat blocked on the relay, holding the session open (and losing the detach message and exit status when the second ctrl+c killed it).

  • The relay now abandons the feed the instant the program exits: one ctrl+c detaches cleanly, prints the re-attach hint, and exits 0 while the run keeps going.

Verification

  • Regression test: the monitor driven with piped input and discarded output, quitting via ctrl+c while the feed channel stays open — previously hung forever, now returns promptly.
  • Live in a PTY (with TERM=dumb so the terminal-capability queries don't stall the headless pty): attach exits 0 at the ctrl+c with the detach message printed, and runs shows the run still running afterward.
  • Full suite with race detector, vet, staticcheck clean.

💘 Generated with Crush

Detaching held the terminal open. The attach monitor's relay goroutine
waited for the journal tailer to close its feed channel — but a
detached run is still going, so its tailer never stops. The tea
program had already exited and restored the terminal, yet the process
sat blocked on the relay, holding the session until a second ctrl+c
killed it outright (losing the detach message and exit status).

The relay now abandons the feed the instant the program exits: one
ctrl+c detaches cleanly, prints the re-attach hint, and exits 0 while
the run keeps going.

The regression test drives the monitor with piped input and discarded
output, quitting with ctrl+c while the feed channel stays open —
previously that hung forever, now it returns promptly. Verified live
in a PTY: attach exits 0 at the ctrl+c with the detach message, and
the run shows still-running afterward.

💘 Generated with Crush

Assisted-by: Crush:rits/zai-org/glm-5-3
@gurnben
gurnben requested a review from a team as a code owner October 21, 2026 16:58
@gurnben
gurnben merged commit f16efcc into main Oct 21, 2026
2 checks passed
@gurnben
gurnben deleted the fix/detach-hang branch October 21, 2026 16:59
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.

1 participant