Repository navigation
Conversation
Guest file descriptors are host CRT descriptors, so dup2 duplicates through the host. A negative or closed source, or a negative target, fails with EBADF; socket and directory descriptors, which live in their own tables, throw. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Guest descriptors are host descriptors, so a guest that moves standard error with dup2 also moves the stream sceKernelDebugOutText writes to. A title that forwards its standard error to the kernel log through a pipe then reads its own debug output back and logs it again without end. Before the guest's first dup2 onto descriptor 2, the host's standard error is kept, and sceKernelDebugOutText writes there. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
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.
|
|
Closing: ccleste (PPSA59322) stops at |
|
@TheAggie Linux (Ubuntu, GCC 15.2.0), That meets the reopen condition in the comment above, if you want to pick it back up. No open PR implements |
|
Windows confirmation of the above, in case it helps reopening: Windows 11 Pro 25H2 (10.0.26200.9457), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release, Prospero Win PPSA99995 (catalog record 0.1.1, sha256 checked),
AI-assisted: yes |
What
dup2was not exported. ccleste (PPSA59322) calls it to move its standard error onto a pipe that it forwards to the kernel log.Two commits:
dup2. Guest file descriptors are host CRT descriptors, sodup2duplicates through the host (_dup2on Windows,dup2elsewhere).EBADF. Duplicating a descriptor onto itself returns it.sceKernelDebugOutTextkeeps the host's standard error. Because guest descriptors are host descriptors, a guest that moves descriptor 2 also moves the streamsceKernelDebugOutTextwrites to. ccleste forwards its standard error into the kernel log, so it read its own debug output back and logged it again without end. Before the guest's firstdup2onto descriptor 2, the host's standard error is duplicated and kept, andsceKernelDebugOutTextwrites there from then on.Tests (
guest_filesystem):EBADFcases are covered.sceKernelDebugOutTextoutput reaches the captured host stream, and a guestwrite(2, ...)reaches the pipe.Not covered: on Windows, the CRT's
_dup2onto descriptor 2 also changes the process'sSTD_ERROR_HANDLE, so AnyPS5's own crash reports written through that handle end up in the guest's pipe too. Restoring the Win32 handle would be a separate change.Tested
Windows 11 Pro (26200), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release.
mainwith this PR and four other small libc/libkernel PRs of mine merged together (atol, getprogname, dup2, ctime/rewind, pthread_set_name_np). It was run from the generatedCTestTestfile.cmakecommands because antivirus blocksctest.exeon this machine.tools/check_conventions.py --base origin/mainpasses on this branch alone.Not tested on Linux or macOS.
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)🤖 Generated with Claude Code