arch/sim: set stdin/stdout nonblocking in host_uart_start() - #20032
Merged
Conversation
to avoid the blocking indefinitely when the host uart is not ready to read/write data. Signed-off-by: chenzihan1 <chenzihan1@xiaomi.com>
When NuttX sim is connected via pipe (e.g. by an automation tool), if the host side does not read stdout in time, the pipe buffer fills up and write(1, ...) blocks the entire sim process. This happens inside host_uninterruptible (irq disabled), so the NuttX scheduler is completely frozen and all threads stop. Set fd=1 (stdout) to O_NONBLOCK so that write() returns EAGAIN instead of blocking. The TX data stays in the NuttX xmit buffer and sim_tty_work retries every 1ms until the pipe has space. Signed-off-by: ligd <liguangdi1@xiaomi.com>
xiaoxiang781216
requested review from
Donny9,
GUIDINGLI and
anchao
as code owners
September 1, 2026 12:30
xiaoxiang781216
force-pushed
the
upstream-sim-hostuart
branch
from
September 1, 2026 12:31
0444dbf to
f6a6981
Compare
Update host_uart_start() to set stdin/stdout nonblocking via ioctl. Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
xiaoxiang781216
force-pushed
the
upstream-sim-hostuart
branch
from
September 1, 2026 12:46
f6a6981 to
e94fe22
Compare
raiden00pl
approved these changes
Sep 2, 2026
acassis
approved these changes
Sep 2, 2026
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
ioctl(FIONBIO)inhost_uart_start().write(1, ...)blocks the entire sim process. This happens insidehost_uninterruptible(irq disabled), so the NuttX scheduler is completely frozen and all threads stop.write()returnsEAGAINinstead; the TX data stays in the NuttX xmit buffer andsim_tty_workretries every 1ms until the pipe has space.Impact
arch/sim/src/sim/posix/sim_hostuart.c), no functional change for interactive terminal usage.Testing
Built and booted
sim:nshon Linux, console I/O works as before; verified the sim no longer freezes when stdout is a pipe that is not drained by the reader.