Repository navigation
fix(libkernel): answer F_GETFD and F_SETFD on a guest socket - #5020
Merged
Merged
Conversation
7 tasks done
10 tasks done
10 tasks done
11 tasks done
11 tasks done
fcntl on a guest socket handled F_GETFL and F_SETFL only and failed every other command with EINVAL, so libcurl's fcntl(fd, F_SETFD, FD_CLOEXEC) on a new socket failed (ProsperoRadio PPSA99001, traced by screamm on boykopovar#4796). Record FD_CLOEXEC per socket descriptor: F_SETFD sets or clears it, F_GETFD reads it, SOCK_CLOEXEC sets it at creation, and dup, dup2 and close start without it, as FreeBSD's kern_fcntl and kern_dup do. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…iptor_flags Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
adriadam10
force-pushed
the
fix/socket-fd-flags
branch
from
October 14, 2026 17:31
863e506 to
c6dcead
Compare
Collaborator
|
Checked on current main (merged and rebased): build + ctest green (169 tests in Added on your branch: rebased onto main (conflict in |
11 tasks done
11 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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