Repository navigation
fix(guest): prevent out-of-order stdout in PTY mode - #62
Merged
Merged
Conversation
DorianZheng
force-pushed
the
fix/pty-stdout-ordering
branch
3 times, most recently
from
January 2, 2026 02:11
7f21473 to
f4e2815
Compare
In PTY mode, stdout and stderr are merged at the PTY level. The previous implementation incorrectly created two separate readers from the same PTY master FD, causing a race condition where data could be captured by the "wrong" reader, resulting in out-of-order output. This fix follows the kata-containers pattern: - Only create ONE reader from the PTY master (stdout) - Pass stderr as None in PTY mode - Non-PTY mode remains unchanged with separate pipes Changes: - exec_handle.rs: Change new() to accept Option<OwnedFd> for stderr - executor.rs: PTY mode passes None, non-PTY wraps stderr in Some() - command.rs: Same pattern, also fix reconcile_pty_fds to return only stdin/stdout
DorianZheng
force-pushed
the
fix/pty-stdout-ordering
branch
from
January 2, 2026 02:14
f4e2815 to
29fddc6
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Problem
In PTY mode, the code incorrectly created two separate readers from the same PTY master:
Both readers had their own
BufReader, causing:Solution
Follow kata-containers pattern:
Nonefor stderr in PTY modeChanges
exec_handle.rsnew()acceptsOption<OwnedFd>for stderrexecutor.rsNone, non-PTY:Some(stderr)command.rsreconcile_pty_fdsTest Plan
interactivebox_example.pyand verify output orderingls /nonexistent 2>&1