[php-src] master: Fix GH-21720: macOS posix_spawn_file_actions_addchdir availability handling
arshidkv12 via Jakub Zelenka <[email protected]>
| Newsgroups | gmane.comp.php.cvs.general |
|---|---|
| Message-ID | <[email protected]> |
Author: arshidkv12 (arshidkv12) Committer: Jakub Zelenka (bukka) Date: 2026-07-12T18:17:57+02:00 Commit: https://github.com/php/php-src/commit/8ce99bc2cec1bb3ff47b5569d573151395bf1fc6 Raw diff: https://github.com/php/php-src/commit/8ce99bc2cec1bb3ff47b5569d573151395bf1fc6.diff Fix GH-21720: macOS posix_spawn_file_actions_addchdir availability handling On Apple, select the addchdir variant by deployment target instead of the configure check: the link check passes whenever the SDK exports the symbol even if the running system is older, leaving a weakly linked reference that resolves to NULL at runtime and crashing proc_open() when $cwd is used. Closes GH-21722 Changed paths: M ext/standard/proc_open.c Diff: diff --git a/ext/standard/proc_open.c b/ext/standard/proc_open.c index 29744018a16d..beeb157e53a5 100644 --- a/ext/standard/proc_open.c +++ b/ext/standard/proc_open.c @@ -42,10 +42,20 @@ * to be really buggy. */ #include <spawn.h> +#ifdef __APPLE__ +#include <AvailabilityMacros.h> +#endif #define USE_POSIX_SPAWN -/* The non-_np variant is in macOS 26 (and _np deprecated) */ -#ifdef HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR +/* The non-_np variant is in macOS 26 (and _np deprecated). On Apple, it has to be selected by the + * deployment target rather than the configure check: the link check passes whenever the SDK + * exports the symbol even if the running system is older, in which case the weakly linked + * reference resolves to NULL at runtime. */ +#if defined(__APPLE__) && MAC_OS_X_VERSION_MIN_REQUIRED >= 260000 +#define POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR posix_spawn_file_actions_addchdir +#elif defined(__APPLE__) +#define POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR posix_spawn_file_actions_addchdir_np +#elif defined(HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR) #define POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR posix_spawn_file_actions_addchdir #else #define POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR posix_spawn_file_actions_addchdir_np