Repository navigation
Apply NuGet.Client close-on-exec fix - #8490
Merged
Merged
Conversation
Port NuGet/NuGet.Client#7643 to the current VMR snapshot without regressing the NuGet source-manifest revision. Co-authored-by: Copilot <[email protected]>
|
Azure Pipelines: Successfully started running 1 pipeline(s). 1 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
Pull request overview
Ports an upstream NuGet.Client fix into the dotnet/dotnet VMR to ensure extracted files are created with close-on-exec semantics on Unix-like platforms, reducing unintended file descriptor inheritance across exec.
Changes:
- Switches the Unix P/Invoke file creation path from
creattoopenwithO_CLOEXECand OS-specific flag values. - Adds OS-specific flag selection for Linux, macOS, and FreeBSD.
- Updates the related CA1303 suppression string to match the new error message text.
Show a summary per file
| File | Description |
|---|---|
| src/nuget-client/src/NuGet.Core/NuGet.Packaging/NuGetExtractionFileIO.cs | Uses open with O_CLOEXEC (and OS-specific flag constants) to create extracted files with close-on-exec behavior. |
| src/nuget-client/src/NuGet.Core/NuGet.Packaging/GlobalSuppressions.cs | Updates suppression text to match the adjusted exception message in NuGetExtractionFileIO. |
Review details
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Suppressed comments (1)
src/nuget-client/src/NuGet.Core/NuGet.Packaging/NuGetExtractionFileIO.cs:90
PosixOpenusesO_WRONLY(viaOpenWriteOnly), but the returnedFileStreamis constructed withFileAccess.ReadWrite. This makes the stream reportCanRead == trueeven though reads will fail with EBADF, and it diverges from the actual underlying descriptor access mode.
Either open with O_RDWR or (simpler since this is only used for writing during extraction) construct the FileStream as write-only to match the flags used.
var sfh = new SafeFileHandle((IntPtr)fd, ownsHandle: true);
try
{
return new FileStream(sfh, FileAccess.ReadWrite);
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Lite
2 of 3 tasks
rbhanda
approved these changes
Aug 20, 2026
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.
Bug
Fixes:
Upstream PR: NuGet/NuGet.Client#7643
Description
Ports NuGet/NuGet.Client#7643 onto the current VMR NuGet.Client snapshot. Extracted files are created with close-on-exec on Linux, macOS, and FreeBSD.
The NuGet source manifest is intentionally unchanged because the upstream PR branch diverged from and is 433 commits behind the current VMR snapshot.
PR Checklist
No tests or documentation changes are needed for this direct port. The affected NuGet.Packaging project builds with zero warnings and errors, and NuGet.sln passes the whitespace verification.