Skip to content

fix(cli): restore terminal settings on console exit#6046

Open
kamalmostafa wants to merge 1 commit into
livekit:mainfrom
kamalmostafa:kamalmostafa/restore-console-tty-on-exit
Open

fix(cli): restore terminal settings on console exit#6046
kamalmostafa wants to merge 1 commit into
livekit:mainfrom
kamalmostafa:kamalmostafa/restore-console-tty-on-exit

Conversation

@kamalmostafa

Copy link
Copy Markdown

In console mode the key-listener runs in a daemon thread that puts the tty into no-echo mode. Ctrl-C tears down the process -- commonly while the key-listener is in mid-read so its per-read restore never gets to run.

The terminal is then left with echo disabled upon process exit.

Fix: Snapshot the tty settings at the start of _run_console and restore them in its finally, which always runs in the main thread on exit, regardless of what state the listener thread might leave the terminal in.

Fixes #6045

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 2 additional findings.

Open in Devin Review

In console mode the key-listener runs in a daemon thread that puts the
tty into no-echo mode. Ctrl-C tears down the process -- commonly while the
key-listener is in mid-read so its per-read restore never gets to run.

The terminal is then left with echo disabled upon process exit.

Fix: Snapshot the tty settings at the start of _run_console and restore
them in its finally, which always runs in the main thread on exit,
regardless of what state the listener thread might leave the terminal in.

Fixes livekit#6045

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@kamalmostafa kamalmostafa force-pushed the kamalmostafa/restore-console-tty-on-exit branch from ec167f2 to 20a3a5b Compare June 11, 2026 13:58
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.

Console mode leaves the tty in no-echo mode after ^C

1 participant