fix(libkernel): select descriptors that are not sockets #1706
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1706"
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 Mubarak-11 on 2026-10-08T17:08:45Z.
1|### What
2|
3|
selectthrewNotImplemented_nid_no_patch("select on descriptors that are not libSceNet sockets")4|for every descriptor it could be asked about, so it never worked for anything. It now polls
5|descriptors below
GuestSockets::FirstDescriptoron the host and keeps the libSceNet poller for6|the rest.
7|
8|The fd space is already partitioned by number —
File/src/Stdio.cppdispatches on9|
d >= GuestSockets::FirstDescriptor— andsceKernelOpenreturns the host descriptor directly,10|so a descriptor below
FirstDescriptoris the host descriptor.selectnow follows the same11|rule: a file-local
HostPollbuildsstruct pollfdand calls::poll, mirroring12|
poll_nid_postfixinSocket/src/Udp.cpp.13|
14|Two behaviours changed with it:
15|
16|- Both
NotImplemented_nid_no_patchcalls are gone. A descriptor the socket poller reports as17|
Unknownis nowEBADF, as is an invalid host descriptor (POLLNVAL).18|-
POLLPRIis not requested for host descriptors. A pipe or regular file has no out-of-band19| data, so
exceptfdscannot become ready for one. Requesting it reported a spurious20| exceptional condition — macOS
pollechoesPOLLPRIback on a pipe when asked for it.21|
22|New test
core/libs/tests/GuestSelect.cpp, registered asguest_selectbesideguest_poll.23|
24|One thing I did not change, because it looks like a design call:
SelectDescriptorLimitis 102425|while
GuestSockets::FirstDescriptoris0x10000000, and the guestfd_setis 1024 bits. So a26|socket can never be represented in a guest
fd_set, and annfdslarge enough to include one is27|rejected as
EINVAL— the socket branch ofselectis unreachable. This change makesselect28|work for the descriptors it can be asked about, rather than changing that limit.
29|
30|Non-socket descriptors still throw on Windows, unchanged, because
WSAPollcannot poll pipes or31|files. Worth a
TechnicalDebt.mdline if you agree.32|
33|### Tested
34|
35|macOS 15.7.4 arm64. The library suite was not run locally:
libkerneldoes not build on macOS36|at all —
File/src/Stdio.cppuses the Linuxstruct dirent64— andlibc/src/JumpBuffer.cppis37|x86-64
setjmp/longjmpassembly with no arm64 path, so the libs are Linux/Windows only. CI's38|Linux job is the first real run of this test.
39|
40|Locally I linked
GuestSelect.cppagainst the realSocket.cpp, withpipe,close,write,41|
readand__errorshimmed to the host syscalls, and ran it both ways:42|
43|- this branch: 23/23 checks pass
44|-
main: exits on the uncaughtselect on descriptors that are not libSceNet socketsexception45|
46|Covered: an empty pipe waits out the timeout and clears the descriptor; a byte written makes the
47|read end ready and leaves
exceptfdsclear; the write end is writable; two descriptors ready at48|once;
nfdsexcludes a descriptor;nfdsabove the limit isEINVAL; a closed descriptor is49|
EBADFrather than a throw.50|
51|### Checklist
main; no other open PR implements the same functions (tools/pr_overlap.py --branchreports no overlap)NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)POLLPRIbehaviour and the before/after runs above are my own checks.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-09T09:29:41Z.
Closing: no title is shown calling
selecton a non-socket descriptor on main, and the change hasn't been run. Reopen when it's a title's next stop on main, with the log line.Pull request closed