|
45 | 45 | #define USE_POSIX_SPAWN |
46 | 46 |
|
47 | 47 | /* The non-_np variant is in macOS 26 (and _np deprecated) */ |
48 | | -#ifdef HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR |
| 48 | +#if defined(__APPLE__) && defined(HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR) && defined(HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR_NP) |
| 49 | +static inline int php_posix_spawn_file_actions_addchdir(posix_spawn_file_actions_t *actions, const char *path) |
| 50 | +{ |
| 51 | +/* The standardized symbol is weak-linked when building with a newer SDK. */ |
| 52 | +# if defined(__clang__) |
| 53 | +# pragma clang diagnostic push |
| 54 | +# pragma clang diagnostic ignored "-Wunguarded-availability-new" |
| 55 | +# endif |
| 56 | + if (posix_spawn_file_actions_addchdir != NULL) { |
| 57 | + return posix_spawn_file_actions_addchdir(actions, path); |
| 58 | + } |
| 59 | +# if defined(__clang__) |
| 60 | +# pragma clang diagnostic pop |
| 61 | +# endif |
| 62 | + |
| 63 | + return posix_spawn_file_actions_addchdir_np(actions, path); |
| 64 | +} |
| 65 | +#define POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR php_posix_spawn_file_actions_addchdir |
| 66 | +#define POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR_NAME "posix_spawn_file_actions_addchdir" |
| 67 | +#elif defined(HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR) |
49 | 68 | #define POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR posix_spawn_file_actions_addchdir |
| 69 | +#define POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR_NAME "posix_spawn_file_actions_addchdir" |
50 | 70 | #else |
51 | 71 | #define POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR posix_spawn_file_actions_addchdir_np |
| 72 | +#define POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR_NAME "posix_spawn_file_actions_addchdir_np" |
52 | 73 | #endif |
53 | 74 | #endif |
54 | 75 |
|
@@ -1401,7 +1422,7 @@ PHP_FUNCTION(proc_open) |
1401 | 1422 | if (cwd) { |
1402 | 1423 | r = POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR(&factions, cwd); |
1403 | 1424 | if (r != 0) { |
1404 | | - php_error_docref(NULL, E_WARNING, ZEND_TOSTR(POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR) "() failed: %s", strerror(r)); |
| 1425 | + php_error_docref(NULL, E_WARNING, POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR_NAME "() failed: %s", strerror(r)); |
1405 | 1426 | } |
1406 | 1427 | } |
1407 | 1428 |
|
|
0 commit comments