Fix terminal echo race condition in monitor for character-by-character input #53
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.
Interactive applications like dmell that read input character-by-character were experiencing duplicate/interleaved characters (typing "ls" → "sls", "echo" → "ecoho") due to a race condition in the monitor's terminal configuration.
Root Cause
The monitor was restoring terminal echo to ON after reading each character. When firmware reads input character-by-character with echo disabled for manual control (using
Dmod_Stdin_SetFlags), the sequence caused:Changes
tools/monitor/monitor.c:monitor_restore_terminal()function with error checking for proper cleanuptools/monitor/main.c:monitor_restore_terminal()on normal exittools/monitor/monitor.h:monitor_restore_terminal()function declarationTesting
Dmod_Stdin_SetFlagsThe monitor now properly respects the
DMLOG_FLAG_INPUT_ECHO_OFFflag without causing race conditions during character-by-character input.Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.