fix(libkernel): fail a write to a pipe without a reader with EPIPE on Windows #11040
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/11040"
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 harisibrar1 on 2026-10-25T14:54:44Z.
What
On Windows, a write to a pipe whose read end is closed fails with
EINVALinstead ofEPIPE.pipegives the guest a host anonymous pipe. When the reader is gone,WriteFilefails withERROR_NO_DATA(232). The UCRT has noerrnomapping for that error and falls back toEINVAL. A standalone check with the same calls (_pipe,_closeof the read end,_write) gives_write=-1 errno=22 _doserrno=232, withGetFileTypereportingFILE_TYPE_PIPE. FreeBSD 11.4'spipe_writereturnsEPIPEonce the read side is lost. So a guest that checks forEPIPEto notice its peer has gone gets an "invalid argument" instead.The two Windows write paths now map the error:
NativeWriteinOpen.cpp(write,_write,sceKernelWrite)NativeTransferBufferinStdio.cpp(writev,sceKernelWritev)When
_writefails on aFILE_TYPE_PIPEhandle withERROR_NO_DATAorERROR_BROKEN_PIPE,errnobecomesEPIPE. A full non-blocking pipe isn't affected: it reports success with 0 bytes, which main already maps toEAGAINon the line above.dofilewritealso sendsSIGPIPE. Nothing is raised on Windows, as main already documents for sockets. The new debt entry records that.Tested
Windows 11, WinLibs GCC 15.2.0 r7, full Release build on main
3a2c51afd2with this change: no failed steps.GuestPosixScalarIo.cpp: after closing the read end,writeand_writefail withEPIPE(32),sceKernelWriteandsceKernelWritevreturn0x80020020, andwritevfails withEPIPE.guest_posix_scalar_io,guest_file_vector,guest_kernel_sysandguest_selectpass, 3 runs of 4/4.guest_kernel_sys_pselectcouldn't start on this machine in that run: Smart App Control blocked the executable. It doesn't write to a closed pipe.Open.cppandStdio.cpp,guest_posix_scalar_iofails at the first new check with guest errno 22 (2 runs).tools/check_conventions.py --base origin/mainpasses._WIN32-only code; Linux and macOS hosts already returnEPIPE.Overlap
pr_overlapreports #11002 (@SandstromPL, which lets a guest ignore or catchSIGPIPEon Linux) on the neighbouring debt line. The new entry says the guest can't ignore the host'sSIGPIPEon Linux "as for sockets above". If #11002 lands first, I'll update that clause to match.Open.cpp/Stdio.cppbut conflict with main and don't touch these lines.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T15:17:26Z.
Review: APPROVED
Reviewed exact head
aebd8881d4. Both Windows write paths map ERROR_NO_DATA and ERROR_BROKEN_PIPE to EPIPE only after a failed write and only for FILE_TYPE_PIPE handles, leaving other errors and non-pipe descriptors untouched. The added Windows regression covers scalar, underscore, kernel, and vector writes. I compiled Open.cpp, Stdio.cpp, and GuestPosixScalarIo.cpp with MinGW syntax-only; MinGW needed a compatibility define for the unrelated missing _fflush_nolock declaration. The author reports Windows negative-control and repeat runs. Hosted product jobs are skipped by path policy, so I did not claim a Windows runtime test here.