Implement SafeProcessHandle APIs for Linux and other Unixes#124979
Implement SafeProcessHandle APIs for Linux and other Unixes#124979Copilot wants to merge 4 commits intocopilot/implement-safeprocesshandle-apisfrom
Conversation
|
Tagging subscribers to this area: @dotnet/area-system-io |
Co-authored-by: adamsitnik <6011991+adamsitnik@users.noreply.github.com>
adamsitnik
left a comment
There was a problem hiding this comment.
@copilot So far I've found only one nit.
Co-authored-by: adamsitnik <6011991+adamsitnik@users.noreply.github.com>
Co-authored-by: adamsitnik <6011991+adamsitnik@users.noreply.github.com>
|
We configure the terminal for
For more info, see dotnet/corefx#35621. |
|
Some other
Exit of
|
|
The Consider: using handle = SafeChildProcessHandle.Start(...);
...
if (!handle.TryWaitForExit(TimeSpan.FromSeconds(1), out _)
handle.Kill();If we're in the case where the child process is killed nothing calls waitpid on the killed child. Its kernel resources won't be returned until the .NET process itself terminates. We added the SIGCHLD handling to deal with this issue for |
src/native/libs/configure.cmakewith new feature detection checks for Linux (clone3, pidfd_send_signal, close_range, pdeathsig, sys_tgkill)src/native/libs/Common/pal_config.h.inwith new#cmakedefine01entries for the new featuressrc/native/libs/System.Native/pal_process.c:sys/syscall.h,linux/sched.h,sys/prctl.hHAVE_PIDFDwhenHAVE_CLONE3is available#else(ENOTSUP) branch inSystemNative_SpawnProcesswith fork/exec path using clone3/fork/vforkSystemNative_SendSignalto usepidfd_send_signalwhen availablemap_wait_status_pidfdusingsiginfo_tfor pidfd pathSystemNative_TryGetExitCodeto usewaitid(P_PIDFD)when pidfd availableSystemNative_WaitForExitAndReapto usewaitid(P_PIDFD)when pidfd availableSystemNative_TryWaitForExitCancellableto usepollwith pidfd when availableSystemNative_TryWaitForExitto usepollwith pidfd when availableSystemNative_OpenProcessto usewaitidverification andpidfd_openwhen availableSafeProcessHandleTests.Unix.csfrom[PlatformSpecific(TestPlatforms.OSX)]to[PlatformSpecific(TestPlatforms.AnyUnix)]SafeProcessHandleTests.csfrom[PlatformSpecific(TestPlatforms.OSX | TestPlatforms.Windows)]to[PlatformSpecific(TestPlatforms.AnyUnix | TestPlatforms.Windows)]sys/syscall.hincludes💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.