Skip to content

Improve Process support on MacCatalyst: use posix_spawn#126478

Open
Copilot wants to merge 9 commits intomainfrom
copilot/improve-process-support-maccatalyst
Open

Improve Process support on MacCatalyst: use posix_spawn#126478
Copilot wants to merge 9 commits intomainfrom
copilot/improve-process-support-maccatalyst

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 2, 2026

MacCatalyst was missing the fast process spawning path available on macOS via posix_spawn. Before this change, MacCatalyst had no working code path in SystemNative_ForkAndExecProcess — it fell through to the #else return -1 fallback with *childPid uninitialized, since both HAVE_FORK (disabled by kernel restriction in configure.cmake) and TARGET_OSX were false for MacCatalyst.

Description

configure.cmake

  • Add check_symbol_exists(posix_spawn_file_actions_addchdir_np spawn.h HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR_NP) to detect availability of posix_spawn_file_actions_addchdir_np at configure time. The existing -Wunguarded-availability flag ensures this check correctly fails for platforms (e.g. MacCatalyst) where the function is marked __API_UNAVAILABLE in the SDK, making the guard future-proof if the function becomes available on those platforms.

src/native/libs/Common/pal_config.h.in

  • Add #cmakedefine01 HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR_NP so the capability macro detected by CMake is emitted into the generated pal_config.h header used by pal_process.c.

Native (pal_process.c)

  • Extend the posix_spawn path to MacCatalyst by changing #if defined(TARGET_OSX) to #if defined(TARGET_OSX) || defined(TARGET_MACCATALYST) for both the argument/initialization guard and the posix_spawn block. Previously, MacCatalyst had no functional code path for process spawning.
  • Extend the leading #if HAVE_FORK || defined(TARGET_OSX) guard to include TARGET_MACCATALYST, ensuring *childPid is properly initialized to -1 and the access() pre-check runs on MacCatalyst.
  • Replace the TARGET_MACCATALYST-specific early-fail block with two capability-based guards:
    • #if !HAVE_FORK — fails fast with errno = ENOTSUP when setCredentials=true, since setuid/setgid-based credential changes require fork, 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 with errno = ENOTSUP when cwd != NULL, since the function is unavailable on MacCatalyst.
  • Guard the posix_spawn_file_actions_addchdir_np call 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.

@dotnet-policy-service
Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @dotnet/area-system-diagnostics-process
See info in area-owners.md if you want to be subscribed.

Copilot AI linked an issue Apr 2, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Improve process support on MacCatalyst Improve Process support on MacCatalyst Apr 2, 2026
Copilot AI requested a review from adamsitnik April 2, 2026 18:47
Copy link
Copy Markdown
Member

@adamsitnik adamsitnik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot please address my feedback

Copilot AI requested review from Copilot and removed request for Copilot April 10, 2026 14:29
Copilot AI changed the title Improve Process support on MacCatalyst Improve Process support on MacCatalyst: use posix_spawn Apr 10, 2026
Copilot AI requested a review from adamsitnik April 10, 2026 14:31
…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>
Copilot AI requested review from Copilot and removed request for Copilot April 10, 2026 16:55
@adamsitnik
Copy link
Copy Markdown
Member

/azp run runtime-maccatalyst

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Copy Markdown
Member

@adamsitnik adamsitnik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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
Copilot AI requested review from adamsitnik and Copilot and removed request for Copilot April 11, 2026 08:45
@adamsitnik
Copy link
Copy Markdown
Member

/azp run runtime-maccatalyst

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve Process support on MacCatalyst

5 participants