Repository navigation
Make descriptors received by recvmsg close-on-exec - #653
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kazu-yamamoto
force-pushed
the
cmsg-cloexec
branch
from
November 15, 2026 09:18
f36b8a2 to
3694f6e
Compare
kazu-yamamoto
added a commit
that referenced
this pull request
Nov 15, 2026
…ted on Windows [skip ci] Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Fix #625.
The fix goes further than adding
MSG_CMSG_CLOEXECas aMsgFlagthat callers can pass.recvBufMsg, whichrecvMsg,recvMsgWithandrecvFdall go through, now always makes the descriptors it receives close-on-exec. This matches whatacceptreturns, which is already close-on-exec on POSIX and, since #655, non-inheritable on Windows.MSG_CMSG_CLOEXECexists (Linux, the BSDs), it is always passed torecvmsg, so the kernel marks the descriptors atomically. Linux echoes the flag back inmsg_flags, so it is masked out of the returned flags.recvBufMsg,recvMsgandrecvFdsay so.sendFd/recvFdtest checks that the received descriptor is close-on-exec.This is a behaviour change: code that hands a received descriptor to a child through exec has to clear the flag itself. Windows is unaffected.
Tested on macOS and on Rocky Linux (GHC 9.12.4).
🤖 Generated with Claude Code