Skip to content

Fix terminal formatting after cog run with an interactive TTY #2424

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 23, 2025

Conversation

michaeldwan
Copy link
Member

#2419 changed how we handle attaching stdin to a container. If stdin is interactive (eg the actual os.Stdin, not a file or pipe) and a TTY we'd set the terminal to raw mode after attaching, and restore to the previous state once detached from the container. This allows cog run to behave correctly when running interactive shells like /bin/bash or a REPL like python.

This PR fixes an issue where the terminal wasn't restored which led to strange behavior like incorrect alignment on the shell prompt. Now instead of restoring in a goroutine which may not complete in time, it's restored in a defer on the main goroutine.

@michaeldwan michaeldwan requested review from a team and 8W9aG June 20, 2025 20:35
@michaeldwan michaeldwan merged commit 07f6a78 into main Jun 23, 2025
48 of 49 checks passed
@michaeldwan michaeldwan deleted the md/tty-raw-fix branch June 23, 2025 23:49
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