fix(libkernel): answer F_GETFD and F_SETFD on a guest socket #5020
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/5020"
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 xXPBSXx on 2026-10-13T08:37:20Z.
What
fcntlon a guest socket answeredF_GETFLandF_SETFLand failed every other command withEINVAL. libcurl callsfcntl(fd, F_SETFD, FD_CLOEXEC)on every new socket, and it failed:mainin this comment on #4796:fcntl(F_SETFD)on a socket returnsEINVAL(the comment lists it among the "smaller mismatches curl tolerates, for later"); libcurl issuesfcntl(fd, F_SETFD, FD_CLOEXEC)on every new socket. The same group of titles (PSXS5, SwanStation, ProsperoTV, ProsperoRadio) uses that libcurl. No title fails because of this answer: curl ignores the error, so the change replaces a wrong answer in the trace of these titles and does not unblock one.F_GETFDandF_SETFDare now answered for a guest socket as FreeBSD 11.4'skern_fcntldoes (FD_CLOEXEC, value 1):F_SETFDsets or clears the flag,F_GETFDreads it back (a new socket starts at 0);SOCK_CLOEXECin the type ofsocketsets it at creation;dupanddup2give the copy no flag (FreeBSD'skern_dupclears it) and leave the original's;closeforgets it, so the next socket on the same number starts at 0.The flag is only recorded: there is no
execin the guest. Not changed, and in the TechnicalDebt entry for libkernel: the other commands on a socket still fail withEINVAL(F_DUPFD,F_DUPFD_CLOEXEC,F_GETOWN,F_SETOWN), and an accepted socket starts without the flag.Overlap: this branch was merged with
main00f4b3351(conflict indocs/dev/debt/libkernel.mdnext to theioctlentry, resolved by keeping both entries;git merge-treeagainstmainis clean). #4954 (fcntlandO_APPEND), #5186 (FIOCLEXandFIONCLEX) and #5569 (ENOTTYfor malformedioctlrequests) touch the same part ofdocs/dev/debt/libkernel.md; whichever lands second rebases its entry.Tested
Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release, head
863e506b2(this branch merged withmain00f4b3351):guest_socket*, including the twelveguest_socket_host_write_*,guest_sce_net,guest_udp,guest_tcp,guest_poll,guest_dup,guest_kernel_fcntl), ctest-V, serial, after building the test executables of exactly these tests (logrun_5020_fix2.log).guest_socket_descriptor_flags(new) is one of them:F_GETFDon a new socket,F_SETFDand read-back,dupanddup2give the copy no flag and keep the original's,F_SETFD 0,SOCK_CLOEXEC, and the next socket after a closed one starts at 0.Udp.cpp(taken frommain, test kept; measured on the previous headb09eccdc4, whoseUdp.cppis the same) it fails:a new socket must not be close-on-exec (F_GETFD 0) (errno 22)(logrun_5020.log).guest_socket_host_write_*tests; the cause was an outdated test executable (not rebuilt). After rebuilding it they pass, here and onmain.python tools/check_conventions.py --base upstream/mainpasses.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt (docs/dev/debt/libkernel.md).mdfiles or images added to the repositoryfcntltrace on their sockets; no bring-up discussion existsAI-assisted (Claude Code).
🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-14T17:31:57Z.
Checked on current main (merged and rebased): build + ctest green (169 tests in
core/libsand libkernel), andguest_socket_descriptor_flagsfails without theUdp.cppchange.F_GETFD/F_SETFD,SOCK_CLOEXEC,dup/dup2andclosematch FreeBSD'skern_fcntl/kern_dup.Added on your branch: rebased onto main (conflict in
docs/dev/debt/libkernel.md, kept both entries) and updated thefcntlentry, which still saidF_GETFD/F_SETFDon a socket fail withEINVAL. Merging once the full Build is green.