Skip to content

[RFC] run-command: add an opt-in posix_spawn backend on macOS - #2267

Draft
JustYannicc wants to merge 1 commit into
gitgitgadget:masterfrom
JustYannicc:rfc/posix-spawn-macos
Draft

JustYannicc wants to merge 1 commit into
gitgitgadget:masterfrom
JustYannicc:rfc/posix-spawn-macos

Conversation

@JustYannicc

Copy link
Copy Markdown

No description provided.

@JustYannicc

Copy link
Copy Markdown
Author

This is my first GitGitGadget submission. Could an existing user please allow JustYannicc with /allow?

This draft is an RFC for an opt-in macOS posix_spawn backend. The single commit contains the rationale, scope, verification and Signed-off-by. Once allowed, I will submit it to the mailing list for feedback on the backend direction.

Platforms that can start child programs but cannot duplicate the parent
process cannot use the POSIX start_command() path. It always calls
fork(), even when the platform supplies a spawn API.

Add USE_POSIX_SPAWN as an opt-in macOS prototype. Keep the existing fork
backend as the default. Reuse command preparation, environment deltas
and child cleanup, and translate the child setup into spawn file
actions and attributes. Preserve the ENOEXEC shell fallback and the
synchronous error reporting expected by start_command() callers.

The macOS implementation provides a concrete place to discuss the
backend boundary before adding another target. It relies on macOS
spawn extensions for cwd and descriptor inheritance. It is not a WASM
port: NO_PTHREADS start_async() still calls fork(), and no wasm child
process has been run with this change.

The RFC question is whether a posix_spawn backend is the right direction
for platforms without fork, or whether Git would prefer a small platform
hook like the existing Windows launch path.

With the opt-in backend, t0061 preloads a macOS test library that makes
fork() return ENOSYS. A canary requires that failure before the launch,
cwd, environment, pipe, error and fallback cases run. The tests call
binaries directly because macOS strips DYLD_* from shell wrappers.

On macOS arm64, DEVELOPER=1 builds and t0061 pass with both backends:
26 cases, with three MINGW skips for spawn and an additional canary
skip for the default backend. Without the test library, the canary
fails as expected. A separate external-alias control also fails on the
default backend when fork() returns ENOSYS.

Meson keeps the prototype disabled. Provide its empty build-option
substitution so the shared template also configures under Meson's
fatal-warning checks. Meson 1.10.1 configuration passes with those checks.

AI assistance: GPT-6.1 Sol and GPT-6 Luna through the Codex harness.

Signed-off-by: Yannic Charlon <justyannicc.8tlny@simplelogin.com>
@JustYannicc
JustYannicc force-pushed the rfc/posix-spawn-macos branch from 0890823 to 6c7ceaf Compare October 18, 2026 18:50
@JustYannicc

Copy link
Copy Markdown
Author

Fixed the Meson configuration failure in the new head. The shared GIT-BUILD-OPTIONS.in entry also needs an empty Meson substitution while this prototype stays Make-only. I reproduced the missing-variable fatal warning with Meson 1.10.1, then verified strict configuration passes with USE_POSIX_SPAWN= in the generated options. The launch implementation and its existing tests are unchanged.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant