Skip to content

fix(libkernel): fail a write to a pipe with no reader with EPIPE on Windows - #5294

Closed
ErenYeager1836 wants to merge 1 commit into
boykopovar:mainfrom
ErenYeager1836:carry/libkernel-pipe-write-epipe
Closed

ErenYeager1836 wants to merge 1 commit into
boykopovar:mainfrom
ErenYeager1836:carry/libkernel-pipe-write-epipe

Conversation

@ErenYeager1836

Copy link
Copy Markdown
Contributor

What

On Windows, the UCRT maps ERROR_NO_DATA (reported by WriteFile when writing to a pipe whose read end has closed) to EINVAL. Consequently, write, writev, sceKernelWrite and sceKernelWritev returned EINVAL instead of FreeBSD's expected EPIPE (32, or SCE error 0x80020020).

  • In NativeWrite and TransferIovecs, maps EINVAL with _doserrno == ERROR_NO_DATA on pipes to EPIPE.
  • Adds dedicated unit test guest_pipe_closed_write covering write, writev, sceKernelWrite and sceKernelWritev on closed blocking and non-blocking pipes.

Carried from @husseinkad with author attribution preserved.

Tested

guest_pipe_closed_write test suite added to ctest. Passes conventions check.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Unblocks: none
  • AI-assisted: yes

…indows

The UCRT maps ERROR_NO_DATA, which WriteFile reports for a pipe whose read
end is closed, to EINVAL. write, writev, sceKernelWrite and sceKernelWritev
returned EINVAL where FreeBSD's pipe_write returns EPIPE.
@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
#5008 core/libs/prx/libkernel/CMakeLists.txt L1212
#5265 core/libs/prx/libkernel/File/src/Stdio.cpp L1011 core/libs/tests/GuestPipeClosedWrite.cpp

@ErenYeager1836

Copy link
Copy Markdown
Contributor Author

Closing as duplicate of #5265, which carries the same change and was opened earlier.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants