fix(libc): return stream errors from fwrite, fread and fputs instead of throwing #4380
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4380"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by AzazelSensei on 2026-10-12T08:21:04Z.
What
fread,fwriteandfputsthrew on an ordinary I/O failure, which takes the whole process down. FreeBSD reports these to the caller instead: fwrite returns the number of complete items written, fread returns a short count with the error flag set, and fputs returns EOF.They now return the host result and keep the guest stream's error flag in sync (
fputswas missing theSyncStatuscall). The throws for null arguments, unwritable buffers and closed streams stay.fflushis left alone since #4372 is changing it.Tested
Linux x86_64,
file_streamstest: writing to anrbstream returns 0 fromfwriteand EOF fromfputswithferrorset, reading from awbstream returns 0 withferrorset. The new cases abort withfread: read failedon currentmain; the existing cases are unchanged and pass.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)