Improve Process support on MacCatalyst: use posix_spawn#126478
Open
Improve Process support on MacCatalyst: use posix_spawn#126478
Conversation
Contributor
|
Tagging subscribers to this area: @dotnet/area-system-diagnostics-process |
Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/821389c5-8982-47c1-80e8-b56290fc0176 Co-authored-by: adamsitnik <6011991+adamsitnik@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Improve process support on MacCatalyst
Improve Process support on MacCatalyst
Apr 2, 2026
adamsitnik
reviewed
Apr 2, 2026
This was referenced Apr 3, 2026
Open
adamsitnik
reviewed
Apr 10, 2026
Member
adamsitnik
left a comment
There was a problem hiding this comment.
@copilot please address my feedback
Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/01f47512-0d0e-42a7-b061-43f1cfb8a932 Co-authored-by: adamsitnik <6011991+adamsitnik@users.noreply.github.com>
Copilot
AI
changed the title
Improve Process support on MacCatalyst
Improve Process support on MacCatalyst: use posix_spawn
Apr 10, 2026
jkotas
approved these changes
Apr 10, 2026
…l-fast rationale Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/f6ebb426-6f64-4c01-aa4e-b667c5bd4d09 Co-authored-by: adamsitnik <6011991+adamsitnik@users.noreply.github.com>
Member
|
/azp run runtime-maccatalyst |
|
Azure Pipelines successfully started running 1 pipeline(s). |
adamsitnik
reviewed
Apr 11, 2026
Member
adamsitnik
left a comment
There was a problem hiding this comment.
@copilot address my feedback
…f TARGET_MACCATALYST guards Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/e578bc53-d1e7-41bb-ad79-023a0863881a Co-authored-by: adamsitnik <6011991+adamsitnik@users.noreply.github.com>
Copilot
AI
requested review from
adamsitnik and
Copilot
and removed request for
Copilot
April 11, 2026 07:38
adamsitnik
reviewed
Apr 11, 2026
Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/c8eaa6ec-270a-4e03-bcbe-07aa37d8fb8a Co-authored-by: adamsitnik <6011991+adamsitnik@users.noreply.github.com>
Copilot
AI
requested review from
adamsitnik and
Copilot
and removed request for
Copilot
April 11, 2026 08:45
Member
|
/azp run runtime-maccatalyst |
|
Azure Pipelines successfully started running 1 pipeline(s). |
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.
MacCatalyst was missing the fast process spawning path available on macOS via
posix_spawn. Before this change, MacCatalyst had no working code path inSystemNative_ForkAndExecProcess— it fell through to the#else return -1fallback with*childPiduninitialized, since bothHAVE_FORK(disabled by kernel restriction inconfigure.cmake) andTARGET_OSXwere false for MacCatalyst.Description
configure.cmakecheck_symbol_exists(posix_spawn_file_actions_addchdir_np spawn.h HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR_NP)to detect availability ofposix_spawn_file_actions_addchdir_npat configure time. The existing-Wunguarded-availabilityflag ensures this check correctly fails for platforms (e.g. MacCatalyst) where the function is marked__API_UNAVAILABLEin the SDK, making the guard future-proof if the function becomes available on those platforms.src/native/libs/Common/pal_config.h.in#cmakedefine01 HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR_NPso the capability macro detected by CMake is emitted into the generatedpal_config.hheader used bypal_process.c.Native (
pal_process.c)posix_spawnpath to MacCatalyst by changing#if defined(TARGET_OSX)to#if defined(TARGET_OSX) || defined(TARGET_MACCATALYST)for both the argument/initialization guard and theposix_spawnblock. Previously, MacCatalyst had no functional code path for process spawning.#if HAVE_FORK || defined(TARGET_OSX)guard to includeTARGET_MACCATALYST, ensuring*childPidis properly initialized to-1and theaccess()pre-check runs on MacCatalyst.TARGET_MACCATALYST-specific early-fail block with two capability-based guards:#if !HAVE_FORK— fails fast witherrno = ENOTSUPwhensetCredentials=true, since setuid/setgid-based credential changes requirefork, which is blocked by the kernel at runtime on MacCatalyst (EPERM). The in-code comment explains this constraint.#if !HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR_NP— fails fast witherrno = ENOTSUPwhencwd != NULL, since the function is unavailable on MacCatalyst.posix_spawn_file_actions_addchdir_npcall site with#if HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR_NP(previously#if !defined(TARGET_MACCATALYST)) to fix the build error and make the guard forward-compatible.