Repository navigation
Closed
Description
- The only way to limit handle inheritance in performant way on apple targets is to use
POSIX_SPAWN_CLOEXEC_DEFAULTsupported byposix_spawn. So it's a must have for Make Process.Start have a option to change handle inheritance #13943. - It would allow us to support
ProcessAPIs on iOS. The only unclear part is testing. - It's the recommended and most performant way to spawn processes on Apple targets. The numbers I got for Prefer posix_spawn on OSX #126063 show even up to x100 boost on arm64 and
x5on x64. - We can't take for granted that it would just work on all the platforms. For example in Don't use vfork on android #118085, we had to switch to
fork(fromvfork) on Android. However, it's worth just asking Copilot to write a prototype and use EgorBot to run some simple benchmarks on Linux x64 and arm64. We should benchmark various scenarios that would include processes that are cheap and expensive to copy . Check https://rust-lang.github.io/rfcs//3228-process-process_group.html for rust approached it. - We still need a fallback to fork/exec to support
setguid,setuidand groups:
runtime/src/native/libs/System.Native/pal_process.c
Lines 406 to 414 in d6c493d
| if (setCredentials) | |
| { | |
| if (SetGroups(groups, groupsLength, getGroupsBuffer) == -1 || | |
| setgid(groupId) == -1 || | |
| setuid(userId) == -1) | |
| { | |
| ExitChild(waitForChildToExecPipe[WRITE_END_OF_PIPE], errno); | |
| } | |
| } |
Activity
dotnet-policy-service commentedon Mar 25, 2026
Tagging subscribers to this area: @dotnet/area-system-diagnostics-process
See info in area-owners.md if you want to be subscribed.
jkotas commentedon Mar 25, 2026
Are you sure? I do not think iOS app sandbox allows launching processes.
jkotas commentedon Mar 25, 2026
How is it going to work when one uses both these features and limited handle inheritance?
adamsitnik commentedon Mar 25, 2026
Please take it with a grain of salt, as I have 0 experience but based on my findings: iOS Sandboxing Prohibits Executing External Binaries, but you can run executables that are inside your app bundle, code‑signed with your app and "permitted by Apple’s policies" (whatever it means)
adamsitnik commentedon Mar 25, 2026
Similarly to other platforms that don't provide a performant way to enforce it (like old Linux kernels), we have at least two options:
FD_CLOEXECflag using fcntl)I would like to recommend to enable this feature by default to some of our tooling (SDK, MSBuild, VS etc), but if we go with option 1 it may cause performance regressions on platforms that we care about (like the old RHEL that we still support). On the other hand, @tmds has put a lot of effort into ensuring dotnet/runtime uses FD_CLOEXEC everywhere by default, so I could also just recommend these tools to do:
@jkotas @stephentoub what would be your preference?
tmds commentedon Mar 25, 2026
close_range was backported to RHEL 8: https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/8/html/8.4_release_notes/new-features