Skip to content

Commit 37cf3aa

Browse files
linesightclaude
andcommitted
Fix QEMU hanging in test mode when stdout is piped
boot.sh --test now redirects stdin from /dev/null before exec'ing QEMU, so QEMU's -nographic serial setup never calls tcsetattr() on a real terminal. When the caller pipes stdout (e.g., through tee) or wraps boot.sh with timeout(1), QEMU runs in a process group that is not the terminal's foreground group; a tcsetattr() call then receives SIGTTOU and stops the process (state Tl), producing no output. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 89c800f commit 37cf3aa

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

devtools/boot.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,13 @@ fi
8686
# Append any extra user-provided QEMU args
8787
QEMU_ARGS+=("${EXTRA_QEMU_ARGS[@]+"${EXTRA_QEMU_ARGS[@]}"}")
8888

89-
exec "$QEMU_BIN" "${QEMU_ARGS[@]}"
89+
# In test mode the guest never reads stdin. Redirect from /dev/null so
90+
# QEMU's -nographic serial setup never calls tcsetattr() on a real
91+
# terminal, which would receive SIGTTOU if the caller piped stdout or
92+
# wrapped boot.sh with timeout(1) (whose child runs in its own process
93+
# group, not the terminal's foreground group).
94+
if [ -n "$TEST_CMD" ]; then
95+
exec "$QEMU_BIN" "${QEMU_ARGS[@]}" < /dev/null
96+
else
97+
exec "$QEMU_BIN" "${QEMU_ARGS[@]}"
98+
fi

0 commit comments

Comments
 (0)