Skip to content

fix(stdio): Ignore WouldBlock errors to match C behavior#154996

Open
skyfireitdiy wants to merge 1 commit intorust-lang:mainfrom
skyfireitdiy:main
Open

fix(stdio): Ignore WouldBlock errors to match C behavior#154996
skyfireitdiy wants to merge 1 commit intorust-lang:mainfrom
skyfireitdiy:main

Conversation

@skyfireitdiy
Copy link
Copy Markdown

Modify the print_to function to silently ignore EAGAIN/WouldBlock errors instead of panicking. This ensures consistent behavior with C language in redirection scenarios (such as Docker containers) and avoids unexpected panics due to non-blocking I/O.

Modify the print_to function to silently ignore EAGAIN/WouldBlock errors instead of panicking. This ensures consistent behavior with C language in redirection scenarios (such as Docker containers) and avoids unexpected panics due to non-blocking I/O.
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Apr 8, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 8, 2026

r? @jhpratt

rustbot has assigned @jhpratt.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: @ChrisDenton, libs
  • @ChrisDenton, libs expanded to 8 candidates
  • Random selection from Mark-Simulacrum, jhpratt

@rust-log-analyzer
Copy link
Copy Markdown
Collaborator

The job aarch64-gnu-llvm-21-1 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
Executing "/scripts/stage_2_test_set1.sh"
+ /scripts/stage_2_test_set1.sh
PR_CI_JOB set; skipping tidy
+ '[' 1 == 1 ']'
+ echo 'PR_CI_JOB set; skipping tidy'
+ SKIP_TIDY='--skip tidy'
+ ../x.py --stage 2 test --skip tidy --skip compiler --skip src
##[group]Building bootstrap
    Finished `dev` profile [unoptimized] target(s) in 0.04s
##[endgroup]
downloading https://static.rust-lang.org/dist/2026-03-05/rustfmt-nightly-aarch64-unknown-linux-gnu.tar.xz

@bjorn3
Copy link
Copy Markdown
Member

bjorn3 commented Apr 9, 2026

So if you are redirecting to a nonblocking pipe or something we will now silently lose (parts) of the written data. That seems to me like it would lead to hard to debug problems as sometimes it works and sometimes it doesn't. And partial writes may completely break things when you are printing some machine readable format rather than a human readable format. If you really need this behavior, you can write your own replacement macros for println!(), print!() and if necessary eprintln!() and eprint!().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants