Skip to content

fix(tty): preserve OPOST chars when output is full#1987

Merged
fslongjin merged 2 commits into
DragonOS-Community:masterfrom
fslongjin:codex/fix-pty-opost-master
Jun 25, 2026
Merged

fix(tty): preserve OPOST chars when output is full#1987
fslongjin merged 2 commits into
DragonOS-Community:masterfrom
fslongjin:codex/fix-pty-opost-master

Conversation

@fslongjin

@fslongjin fslongjin commented Jun 25, 2026

Copy link
Copy Markdown
Member

Summary

  • distinguish OPOST output-buffer-full from valid zero-output consumption in n_tty
  • keep ONLCR-expanded characters pending when PTY output space cannot fit the full expansion
  • provide /bin/true and /bin/false from coreutils in the rootfs for Linux-compatible absolute paths used by gVisor tests

Root Cause

process_output_char_to_buf() returned ENOBUFS with an empty temporary output buffer when OPOST | ONLCR needed to expand \n into \r\n but only one output byte of room was available. The caller then treated the empty buffer as a valid consumed-without-output character and advanced the input offset, silently dropping the input newline.

Linux n_tty keeps these states distinct: output full means retry without consuming input, while ONOCR at column zero is a valid zero-output consume.

The follow-up Integration Test failure in Waiters/WaitSpecificChildTest.AfterChildExecve/{0,1} matched the current origin/master baseline failure at e7331811004d725d8303b2ee01878d425ebba63d: the test execs /bin/true, while the DragonOS rootfs only installed coreutils true under /usr/local/bin/true. The child therefore exited with ENOENT (2), and wait observed status 512 / 2.

Validation

  • make kernel
  • make user
  • TOML parse check for user/dadk/config/all/core_utils-9.4.0.toml
  • Verified generated coreutils build output and local sysroot contain static ELF files at:
    • bin/dadk_cache/build/core_utils_9_4_0/bin/true
    • bin/dadk_cache/build/core_utils_9_4_0/bin/false
    • bin/sysroot/bin/true
    • bin/sysroot/bin/false
  • Earlier PTY-focused validation:
    • make fmt
    • FORCE_UNSAFE_CONFIGURE=1 DUNITEST_PATTERN=normal/tty_pty_hangup make test-dunit
      • The current Makefile did not propagate DUNITEST_PATTERN into the guest, so this ran full dunitest.
      • Result: 419 total, 410 passed, 0 failed, 9 skipped.
      • TtyPtyHangup.TciflushDoesNotDiscardLargeOpostSlaveOutput passed in 27 ms.

@github-actions github-actions Bot added Bug fix A bug is fixed in this pull request test Unitest/User space test labels Jun 25, 2026
@fslongjin fslongjin marked this pull request as ready for review June 25, 2026 06:56
@fslongjin

Copy link
Copy Markdown
Member Author

@codex review

Signed-off-by: longjin <longjin@dragonos.org>
@fslongjin fslongjin force-pushed the codex/fix-pty-opost-master branch from 45a3f3f to 140b043 Compare June 25, 2026 06:57
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: 45a3f3f3e4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Signed-off-by: longjin <longjin@dragonos.org>
@fslongjin fslongjin merged commit 9ca7e8b into DragonOS-Community:master Jun 25, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug fix A bug is fixed in this pull request test Unitest/User space test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant