Repository navigation
Commit 0890823
Yannic Charlon
run-command: add an opt-in posix_spawn backend on macOS
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.
AI assistance: GPT-6.1 Sol and GPT-6 Luna through the Codex harness.
Signed-off-by: Yannic Charlon <justyannicc.8tlny@simplelogin.com>1 parent c514088 commit 0890823
7 files changed
Lines changed: 356 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| 47 | + | |
47 | 48 | | |
48 | 49 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
149 | 149 | | |
150 | 150 | | |
151 | 151 | | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
152 | 155 | | |
153 | 156 | | |
154 | 157 | | |
| |||
889 | 892 | | |
890 | 893 | | |
891 | 894 | | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
892 | 899 | | |
893 | 900 | | |
894 | 901 | | |
| |||
2247 | 2254 | | |
2248 | 2255 | | |
2249 | 2256 | | |
| 2257 | + | |
| 2258 | + | |
| 2259 | + | |
| 2260 | + | |
2250 | 2261 | | |
2251 | 2262 | | |
2252 | 2263 | | |
| |||
3387 | 3398 | | |
3388 | 3399 | | |
3389 | 3400 | | |
| 3401 | + | |
3390 | 3402 | | |
3391 | 3403 | | |
3392 | 3404 | | |
| |||
3408 | 3420 | | |
3409 | 3421 | | |
3410 | 3422 | | |
3411 | | - | |
| 3423 | + | |
3412 | 3424 | | |
3413 | 3425 | | |
3414 | 3426 | | |
| |||
3442 | 3454 | | |
3443 | 3455 | | |
3444 | 3456 | | |
3445 | | - | |
| 3457 | + | |
3446 | 3458 | | |
3447 | 3459 | | |
3448 | 3460 | | |
3449 | 3461 | | |
| 3462 | + | |
| 3463 | + | |
| 3464 | + | |
| 3465 | + | |
| 3466 | + | |
3450 | 3467 | | |
3451 | 3468 | | |
3452 | 3469 | | |
| |||
3918 | 3935 | | |
3919 | 3936 | | |
3920 | 3937 | | |
3921 | | - | |
| 3938 | + | |
3922 | 3939 | | |
3923 | 3940 | | |
3924 | 3941 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
21 | 43 | | |
22 | 44 | | |
23 | 45 | | |
| |||
309 | 331 | | |
310 | 332 | | |
311 | 333 | | |
| 334 | + | |
312 | 335 | | |
| 336 | + | |
313 | 337 | | |
314 | 338 | | |
315 | 339 | | |
| |||
325 | 349 | | |
326 | 350 | | |
327 | 351 | | |
| 352 | + | |
328 | 353 | | |
329 | 354 | | |
330 | 355 | | |
| |||
373 | 398 | | |
374 | 399 | | |
375 | 400 | | |
| 401 | + | |
376 | 402 | | |
377 | 403 | | |
378 | 404 | | |
| |||
496 | 522 | | |
497 | 523 | | |
498 | 524 | | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
499 | 708 | | |
500 | 709 | | |
501 | 710 | | |
| |||
545 | 754 | | |
546 | 755 | | |
547 | 756 | | |
| 757 | + | |
548 | 758 | | |
549 | 759 | | |
550 | 760 | | |
| |||
746 | 956 | | |
747 | 957 | | |
748 | 958 | | |
| 959 | + | |
749 | 960 | | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
| 976 | + | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
750 | 990 | | |
751 | 991 | | |
752 | 992 | | |
| |||
905 | 1145 | | |
906 | 1146 | | |
907 | 1147 | | |
908 | | - | |
909 | 1148 | | |
| 1149 | + | |
| 1150 | + | |
| 1151 | + | |
910 | 1152 | | |
911 | 1153 | | |
912 | 1154 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
0 commit comments