Draft
Conversation
Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/f57caa85-c528-444f-ab43-a628d6ddd488 Co-authored-by: adamsitnik <6011991+adamsitnik@users.noreply.github.com>
Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/f57caa85-c528-444f-ab43-a628d6ddd488 Co-authored-by: adamsitnik <6011991+adamsitnik@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
adamsitnik
April 9, 2026 12:38
View session
adamsitnik
reviewed
Apr 9, 2026
Member
adamsitnik
left a comment
There was a problem hiding this comment.
@copilot give my feedback a try. Run all process tests and ensure they pass before you push any changes.
Contributor
|
Tagging subscribers to this area: @dotnet/area-system-diagnostics-process |
…ss with outPidfd parameter Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/664957d4-993f-4f40-aa79-ce45ec55fd11 Co-authored-by: adamsitnik <6011991+adamsitnik@users.noreply.github.com>
Contributor
Author
adamsitnik
reviewed
Apr 9, 2026
Member
adamsitnik
left a comment
There was a problem hiding this comment.
@copilot address my feedback
src/libraries/Common/src/Interop/Unix/System.Native/Interop.ForkAndExecProcess.cs
Outdated
Show resolved
Hide resolved
src/libraries/Common/src/Interop/Unix/System.Native/Interop.ForkAndExecProcess.cs
Outdated
Show resolved
Hide resolved
…acOS posix_spawn path Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/ed9ebae7-b0ac-4a66-a222-8f7305c55a9b Co-authored-by: adamsitnik <6011991+adamsitnik@users.noreply.github.com>
Contributor
Author
This was referenced Apr 9, 2026
Open
This was referenced Apr 9, 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.
Description
Implements
SafeProcessHandle.Open(int processId)— opens an existing process by PID and returns aSafeProcessHandle.OpenProcesswithPROCESS_QUERY_LIMITED_INFORMATION | SYNCHRONIZE | PROCESS_TERMINATE.pidfd_opensyscall when available, falls back tokill(pid, 0).kill(pid, 0)to verify process existence and signal permission.Changes
ref/System.Diagnostics.Process.cs): AddedOpendeclaration with platform attributesSafeProcessHandle.cs):Openmethod with argument validation, XML docs,[UnsupportedOSPlatform]/[SupportedOSPlatform]attributesSafeProcessHandle.Windows.cs):OpenCoreviaInterop.Kernel32.OpenProcessSafeProcessHandle.Unix.cs):OpenCoreviaInterop.Sys.OpenProcess, added_pidfdfield with cleanup inReleaseHandle, new private constructor for pidfd-backed handles.ForkAndExecProcessnow also populates_pidfdso child processes started viaStart()get a pidfd on Linux.pal_process.c/h): ExtractedTryOpenPidfdas a reusable linux-specific helper forpidfd_open. ExtendedSystemNative_ForkAndExecProcesswithint32_t* outPidfdparameter — populated viaTryOpenPidfdon the fork path (Linux), set to-1on the posix_spawn path (macOS).SystemNative_OpenProcessalso reuses the same helper. AddedSYS_pidfd_opendefine (matching__NR_close_rangepattern), WASI stub, entrypoint registration.Interop.OpenProcess.cs): New Unix P/Invoke forSystemNative_OpenProcessInterop.ForkAndExecProcess.cs): Extended P/Invoke and managed wrapper without intparameter (matching theout int lpChildPidpattern) to read pidfd from native layerSafeProcessHandleTests.cs): Argument validation, non-existent PID, open running process, open-then-killTesting