From 293b38bc9db23573a7fa28e5c86c0cfdac8b5341 Mon Sep 17 00:00:00 2001 From: arshidkv12 Date: Sat, 11 Apr 2026 13:51:11 +0530 Subject: [PATCH 1/6] Fix macOS posix_spawn_file_actions_addchdir availability handling --- ext/standard/proc_open.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/ext/standard/proc_open.c b/ext/standard/proc_open.c index ddce144161ca..304d3e519995 100644 --- a/ext/standard/proc_open.c +++ b/ext/standard/proc_open.c @@ -47,11 +47,26 @@ #define USE_POSIX_SPAWN /* The non-_np variant is in macOS 26 (and _np deprecated) */ -#ifdef HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR -#define POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR posix_spawn_file_actions_addchdir +static inline int php_spawn_addchdir( + posix_spawn_file_actions_t *factions, + const char *cwd +) { +#if defined(__APPLE__) + if (__builtin_available(macOS 26.0, *)) { + return posix_spawn_file_actions_addchdir(factions, cwd); + } else { + return posix_spawn_file_actions_addchdir_np(factions, cwd); + } +#elif defined(HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR) + return posix_spawn_file_actions_addchdir(factions, cwd); #else -#define POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR posix_spawn_file_actions_addchdir_np + return posix_spawn_file_actions_addchdir_np(factions, cwd); #endif +} + +#define POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR(f, d) \ + php_spawn_addchdir((f), (d)) + #endif /* This symbol is defined in ext/standard/config.m4. From d8a3e82bb0c39671688119da76a8d66fba509cb9 Mon Sep 17 00:00:00 2001 From: arshidkv12 Date: Sat, 11 Apr 2026 14:02:09 +0530 Subject: [PATCH 2/6] Fix macOS posix_spawn_file_actions_addchdir availability handling --- ext/standard/proc_open.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/standard/proc_open.c b/ext/standard/proc_open.c index 304d3e519995..9807aa08a490 100644 --- a/ext/standard/proc_open.c +++ b/ext/standard/proc_open.c @@ -51,7 +51,7 @@ static inline int php_spawn_addchdir( posix_spawn_file_actions_t *factions, const char *cwd ) { -#if defined(__APPLE__) +#if defined(__APPLE__) && defined(HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR) if (__builtin_available(macOS 26.0, *)) { return posix_spawn_file_actions_addchdir(factions, cwd); } else { From 0149360ac9c6e6f41ca4fddddb4323f9a3f96faa Mon Sep 17 00:00:00 2001 From: arshidkv12 Date: Mon, 13 Apr 2026 20:53:54 +0530 Subject: [PATCH 3/6] Fix macOS posix_spawn_file_actions_addchdir availability handling --- ext/standard/proc_open.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/ext/standard/proc_open.c b/ext/standard/proc_open.c index 9807aa08a490..6c437cc17fa9 100644 --- a/ext/standard/proc_open.c +++ b/ext/standard/proc_open.c @@ -47,21 +47,18 @@ #define USE_POSIX_SPAWN /* The non-_np variant is in macOS 26 (and _np deprecated) */ +#if defined(__APPLE__) && defined(HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR) && \ + defined(MAC_OS_X_VERSION_MIN_REQUIRED) && MAC_OS_X_VERSION_MIN_REQUIRED >= 260000 + #define USE_ADDCHDIR posix_spawn_file_actions_addchdir +#else + #define USE_ADDCHDIR posix_spawn_file_actions_addchdir_np +#endif + static inline int php_spawn_addchdir( posix_spawn_file_actions_t *factions, const char *cwd ) { -#if defined(__APPLE__) && defined(HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR) - if (__builtin_available(macOS 26.0, *)) { - return posix_spawn_file_actions_addchdir(factions, cwd); - } else { - return posix_spawn_file_actions_addchdir_np(factions, cwd); - } -#elif defined(HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR) - return posix_spawn_file_actions_addchdir(factions, cwd); -#else - return posix_spawn_file_actions_addchdir_np(factions, cwd); -#endif + return USE_ADDCHDIR(factions, cwd); } #define POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR(f, d) \ From c4bb7ab1ef1f73a4c232ec1e13a8a23eaeecab98 Mon Sep 17 00:00:00 2001 From: arshidkv12 Date: Mon, 13 Apr 2026 21:02:53 +0530 Subject: [PATCH 4/6] Fix macOS posix_spawn_file_actions_addchdir availability handling --- ext/standard/proc_open.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/ext/standard/proc_open.c b/ext/standard/proc_open.c index 6c437cc17fa9..f730444a3571 100644 --- a/ext/standard/proc_open.c +++ b/ext/standard/proc_open.c @@ -47,24 +47,17 @@ #define USE_POSIX_SPAWN /* The non-_np variant is in macOS 26 (and _np deprecated) */ -#if defined(__APPLE__) && defined(HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR) && \ - defined(MAC_OS_X_VERSION_MIN_REQUIRED) && MAC_OS_X_VERSION_MIN_REQUIRED >= 260000 - #define USE_ADDCHDIR posix_spawn_file_actions_addchdir +# if defined(MAC_OS_X_VERSION_MIN_REQUIRED) && MAC_OS_X_VERSION_MIN_REQUIRED >= 260000 + #define POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR posix_spawn_file_actions_addchdir +# else + #define POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR posix_spawn_file_actions_addchdir_np +# endif +#elif defined(HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR) + #define POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR posix_spawn_file_actions_addchdir #else - #define USE_ADDCHDIR posix_spawn_file_actions_addchdir_np + #define POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR posix_spawn_file_actions_addchdir_np #endif -static inline int php_spawn_addchdir( - posix_spawn_file_actions_t *factions, - const char *cwd -) { - return USE_ADDCHDIR(factions, cwd); -} - -#define POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR(f, d) \ - php_spawn_addchdir((f), (d)) - -#endif /* This symbol is defined in ext/standard/config.m4. * Essentially, it is set if you HAVE_FORK || PHP_WIN32 From e18941415a450dfbb5bb8329501e9c038d1c748e Mon Sep 17 00:00:00 2001 From: arshidkv12 Date: Mon, 13 Apr 2026 21:14:26 +0530 Subject: [PATCH 5/6] Fix macOS posix_spawn_file_actions_addchdir availability handling --- ext/standard/proc_open.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/ext/standard/proc_open.c b/ext/standard/proc_open.c index f730444a3571..c7db4dac8983 100644 --- a/ext/standard/proc_open.c +++ b/ext/standard/proc_open.c @@ -47,15 +47,23 @@ #define USE_POSIX_SPAWN /* The non-_np variant is in macOS 26 (and _np deprecated) */ -# if defined(MAC_OS_X_VERSION_MIN_REQUIRED) && MAC_OS_X_VERSION_MIN_REQUIRED >= 260000 - #define POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR posix_spawn_file_actions_addchdir -# else - #define POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR posix_spawn_file_actions_addchdir_np -# endif +#if defined(__APPLE__) && MAC_OS_X_VERSION_MIN_REQUIRED <= 260000 + +#define POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR posix_spawn_file_actions_addchdir_np + +#elif defined(__APPLE__) && defined(MAC_OS_X_VERSION_MIN_REQUIRED) && MAC_OS_X_VERSION_MIN_REQUIRED >= 26000 + +#define POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR posix_spawn_file_actions_addchdir + #elif defined(HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR) - #define POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR 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 + +#define POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR posix_spawn_file_actions_addchdir_np + +#endif #endif From f1e3800a2b49312d8c99efd234ee33e1a6daa075 Mon Sep 17 00:00:00 2001 From: arshidkv12 Date: Mon, 13 Apr 2026 21:30:52 +0530 Subject: [PATCH 6/6] Fix macOS posix_spawn_file_actions_addchdir availability handling --- ext/standard/proc_open.c | 36 ++++++++++++++---------------------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/ext/standard/proc_open.c b/ext/standard/proc_open.c index c7db4dac8983..319f11fd1e72 100644 --- a/ext/standard/proc_open.c +++ b/ext/standard/proc_open.c @@ -1,14 +1,12 @@ /* +----------------------------------------------------------------------+ - | Copyright (c) The PHP Group | + | Copyright © The PHP Group and Contributors. | +----------------------------------------------------------------------+ - | This source file is subject to version 3.01 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | https://www.php.net/license/3_01.txt | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | + | This source file is subject to the Modified BSD License that is | + | bundled with this package in the file LICENSE, and is available | + | through the World Wide Web at . | + | | + | SPDX-License-Identifier: BSD-3-Clause | +----------------------------------------------------------------------+ | Author: Wez Furlong | +----------------------------------------------------------------------+ @@ -44,29 +42,23 @@ * to be really buggy. */ #include +#ifdef __APPLE__ +#include +#endif #define USE_POSIX_SPAWN /* The non-_np variant is in macOS 26 (and _np deprecated) */ -#if defined(__APPLE__) && MAC_OS_X_VERSION_MIN_REQUIRED <= 260000 - -#define POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR posix_spawn_file_actions_addchdir_np - -#elif defined(__APPLE__) && defined(MAC_OS_X_VERSION_MIN_REQUIRED) && MAC_OS_X_VERSION_MIN_REQUIRED >= 26000 - +#if defined(__APPLE__) && MAC_OS_X_VERSION_MIN_REQUIRED >= 260000 #define POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR posix_spawn_file_actions_addchdir - -#elif defined(HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR) - +#elif defined(__APPLE__) && MAC_OS_X_VERSION_MIN_REQUIRED < 260000 +#define POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR posix_spawn_file_actions_addchdir_np +#elif 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 - #endif #endif - /* This symbol is defined in ext/standard/config.m4. * Essentially, it is set if you HAVE_FORK || PHP_WIN32 * Other platforms may modify that configure check and add suitable #ifdefs @@ -1586,4 +1578,4 @@ PHP_FUNCTION(proc_open) } /* }}} */ -#endif /* PHP_CAN_SUPPORT_PROC_OPEN */ +#endif /* PHP_CAN_SUPPORT_PROC_OPEN */ \ No newline at end of file