|
35 | 35 | #include <fcntl.h> |
36 | 36 | #endif |
37 | 37 |
|
38 | | -#ifdef HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR_NP |
| 38 | +#if defined(HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR_NP) || defined(HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR) |
39 | 39 | /* Only defined on glibc >= 2.29, FreeBSD CURRENT, musl >= 1.1.24, |
40 | 40 | * MacOS Catalina or later.. |
41 | 41 | * It should be posible to modify this so it is also |
|
44 | 44 | * to be really buggy. |
45 | 45 | */ |
46 | 46 | #include <spawn.h> |
| 47 | +#ifdef __APPLE__ |
| 48 | +#include <AvailabilityMacros.h> |
| 49 | +#endif |
47 | 50 | #define USE_POSIX_SPAWN |
| 51 | + |
| 52 | +/* The non-_np variant is in macOS 26 (and _np deprecated). On Apple, it has to be selected by the |
| 53 | + * deployment target rather than the configure check: the link check passes whenever the SDK |
| 54 | + * exports the symbol even if the running system is older, in which case the weakly linked |
| 55 | + * reference resolves to NULL at runtime. */ |
| 56 | +#if defined(__APPLE__) && MAC_OS_X_VERSION_MIN_REQUIRED >= 260000 |
| 57 | +#define POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR posix_spawn_file_actions_addchdir |
| 58 | +#elif defined(__APPLE__) |
| 59 | +#define POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR posix_spawn_file_actions_addchdir_np |
| 60 | +#elif defined(HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR) |
| 61 | +#define POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR posix_spawn_file_actions_addchdir |
| 62 | +#else |
| 63 | +#define POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR posix_spawn_file_actions_addchdir_np |
| 64 | +#endif |
48 | 65 | #endif |
49 | 66 |
|
50 | 67 | /* This symbol is defined in ext/standard/config.m4. |
@@ -1391,9 +1408,9 @@ PHP_FUNCTION(proc_open) |
1391 | 1408 | } |
1392 | 1409 |
|
1393 | 1410 | if (cwd) { |
1394 | | - r = posix_spawn_file_actions_addchdir_np(&factions, cwd); |
| 1411 | + r = POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR(&factions, cwd); |
1395 | 1412 | if (r != 0) { |
1396 | | - php_error_docref(NULL, E_WARNING, "posix_spawn_file_actions_addchdir_np() failed: %s", strerror(r)); |
| 1413 | + php_error_docref(NULL, E_WARNING, ZEND_TOSTR(POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR) "() failed: %s", strerror(r)); |
1397 | 1414 | } |
1398 | 1415 | } |
1399 | 1416 |
|
|
0 commit comments